Beispiel #1
0
    private void UpdateMaxActiveCampaignsLiteralText()
    {
        int activeCampaigns = PtcAdvert.GetUserActiveCampaignsCount(Member.CurrentId);

        MaxActiveCampaignsLiteral.Text = U5007.MAXACTIVEADCAMPAINS + ": " + activeCampaigns
                                         + "/" + Member.CurrentInCache.Membership.MaxActivePtcCampaignLimit;
    }
Beispiel #2
0
    protected void StartPageDateCalendar_DayRender(object sender, DayRenderEventArgs e)
    {
        if (e.Day.Date <= DateTime.Now.Date)
        {
            e.Day.IsSelectable = false;
            e.Cell.ForeColor   = System.Drawing.ColorTranslator.FromHtml("#FFBBBBBB");
            return;
        }

        bool isFull = PtcAdvert.GetNumberOfStartPagesPurchasedForDay(e.Day.Date) > 0;

        if (isFull)
        {
            e.Cell.BackColor = System.Drawing.ColorTranslator.FromHtml("#FFE7D5D5");
            e.Cell.ForeColor = System.Drawing.ColorTranslator.FromHtml("White");

            e.Day.IsSelectable = false;
        }
        else
        {
            e.Cell.BackColor = System.Drawing.ColorTranslator.FromHtml("#FFD0DECE");
            e.Cell.ForeColor = System.Drawing.ColorTranslator.FromHtml("White");
        }

        if (e.Day.IsSelected)
        {
            e.Cell.BackColor = System.Drawing.ColorTranslator.FromHtml("#FFE2E499");
        }
    }
    public Money Credit(PtcAdvert ad)
    {
        Money calculated = ad.MoneyToClaimAsCashLink;

        user.AddToMainBalance(calculated, "CashLink", BalanceLogType.CashLinkClick);
        user.IncreaseEarnings(calculated);

        //OK mark as watched and credit
        List <int> av = user.AdsViewed;

        av.Add(ad.Id);
        user.AdsViewed  = av;
        user.LastActive = DateTime.Now;

        Money NewTotalEarned = (user.TotalEarned + calculated);

        user.TryToAddAchievements(
            Prem.PTC.Achievements.Achievement.GetProperAchievements(
                Prem.PTC.Achievements.AchievementType.AfterEarning, NewTotalEarned.GetRealTotals()));

        user.IncreaseUserStatClicks(1);
        user.IncreaseStatClicks(1);
        user.IncreaseCashLinksEarnings(calculated);

        user.Save();

        DailyPoolManager.AddToPool(PoolsHelper.GetBuiltInProfitPoolId(Pools.AdPackRevenueReturn), DateTime.Now, calculated);
        AdPackProfitDistributionHistory.Add(calculated);

        return(calculated);
    }
Beispiel #4
0
        /// <summary>
        /// Handles direct referrals too, IT IS Fired after every successful watch ad action
        /// </summary>
        public void IClicked(PtcAdvert Ad)
        {
            using (var bridge = ParserPool.Acquire(Database.Client))
            {
                //Get all rented referrals "fired by" (normal and bots) the user
                string    Command         = "SELECT * FROM RentedReferrals WHERE BotClass <> 0 AND FiredBy = '" + Username + "'";
                DataTable result          = bridge.Instance.ExecuteRawCommandToDataTable(Command);
                var       InterestingList = TableHelper.GetListFromDataTable <RentedReferral>(result, 100, true);

                foreach (RentedReferral referral in InterestingList)
                {
                    //Referral management
                    referral.LastClick = DateTime.Now;
                    referral.TotalClicks++;
                    //Stats
                    List <int> statlist = TableHelper.GetIntListFromString(referral.ClicksStats);
                    statlist[0]++;
                    referral.ClicksStats = TableHelper.GetStringFromIntList(statlist);
                    referral.Save();

                    //Add money to owneruser if can
                    Member OwnerUser = new Member(referral.OwnerUsername);
                    HandleOwnerUser(OwnerUser, Ad);
                }
            }
        }
Beispiel #5
0
        public Money Credit(PtcAdvert Ad)
        {
            Money Calculated = Ad.MoneyToClaimAsCashLink;

            base.CreditMainBalance(Calculated, "CashLink", BalanceLogType.CashLinkClick, false);

            //OK mark as watched and credit
            List <int> av = User.AdsViewed;

            av.Add(Ad.Id);
            User.AdsViewed  = av;
            User.LastActive = DateTime.Now;

            Money NewTotalEarned = (User.TotalEarned + Calculated);

            User.TryToAddAchievements(
                Prem.PTC.Achievements.Achievement.GetProperAchievements(
                    Prem.PTC.Achievements.AchievementType.AfterEarning, NewTotalEarned.GetRealTotals()));

            User.IncreaseUserStatClicks(1);
            User.IncreaseStatClicks(1);
            User.IncreaseCashLinksEarnings(Calculated);

            //Now let's credit the referrer
            CreditReferersMainBalance(Ad.MoneyToClaimAsCashLink, "CashLink /ref/" + User.Name, BalanceLogType.CashLinkRefClick, 1, null, false);

            User.Save();

            return(Calculated);
        }
Beispiel #6
0
    private void BindDataToDDL()
    {
        var where = TableHelper.MakeDictionary("IsVisibleByMembers", true);

        if (AppSettings.PtcAdverts.PTCCreditsEnabled)
        {
            where["EndMode"] = (int)End.Mode.Clicks;
        }

        var listPacks = TableHelper.SelectRows <PtcAdvertPack>(where);

        listPacks.Sort(PtcAdvertManager.PackComparision);
        var list = new Dictionary <string, string>();

        foreach (PtcAdvertPack pack in listPacks)
        {
            string ends = L1.NEVER;
            if (pack.Ends.EndMode == End.Mode.Days)
            {
                ends = pack.Ends.Value.ToString() + " " + L1.DAYS;
            }
            else if (pack.Ends.EndMode == End.Mode.Clicks)
            {
                ends = pack.Ends.Value.ToString() + " " + L1.VIEWS;
            }

            Money     price;
            PtcAdvert ad = null;

            try
            {
                ad = new PtcAdvert(Convert.ToInt32(ViewState["editid"]));
            }
            catch { }

            if (ad != null && ad.Pack.Id == pack.Id)
            {
                price = ad.PackPrice;
            }
            else
            {
                price = PtcAdvertManager.GetDiscountedPTCPackPrice(pack);
            }

            string value = ends + " (" + pack.DisplayTime.TotalSeconds.ToString() + "s) - " + price.ToString();

            if (AppSettings.PtcAdverts.AdvertPTCPackCashbackEnabled && pack.PTCPackCashBackPercent != 0)
            {
                value += String.Format(" - {0}% cashback", pack.PTCPackCashBackPercent);
            }

            list.Add(pack.Id.ToString(), value);
        }
        ddlOptions.DataSource     = list;
        ddlOptions.DataTextField  = "Value";
        ddlOptions.DataValueField = "Key";

        ddlOptions.DataBind();
    }
Beispiel #7
0
    protected void ProcceedWithCredit(int Id)
    {
        //Stats
        var targetStatValue = new Prem.PTC.Statistics.Statistics(Prem.PTC.Statistics.StatisticsType.PTCClicks);

        targetStatValue.AddToData1(1);
        targetStatValue.Save();

        if (Member.IsLogged)
        {
            RegisterUserValidationSummary.Visible = true;
            //Anti-cheat: Check if ad is not already watched
            var User = Member.GetLoggedMember(Context);
            if (User.AdsViewed.Contains(Id))
            {
                DisplayInfo(L1.ALREADYWATCHED, false);
            }
            else
            {
                CaptchaPanel.Visible = false;

                var ad = new PtcAdvert(Id);

                //Use Crediter
                PtcCrediter Crediter   = (PtcCrediter)CrediterFactory.Acquire(User, Titan.CreditType.PTC);
                Money       Calculated = Crediter.CreditMember(ad);

                DisplayInfo(L1.YOUVEBEENCREDITED + " <b>" + Calculated.ToString() + "</b> " +
                            L1.AND + " <b>" + User.Membership.AdvertPointsEarnings.ToString() + "</b> " + AppSettings.PointsName + " " + L1.FORTHISAD, true);

                //Display "Feel free with Ad URL" text
                FeelFreeLiteral.Text = ": <a href=\"" + ad.TargetUrl + "\" target=\"_blank\">" + ad.TargetUrl + "</a>";

                //Force notifiaction refresh (Ads)
                NotificationManager.RefreshWithMember(NotificationType.NewAds, User);

                //Modify the ad info
                ad.Click();
                if (ad.ShouldBeFinished)
                {
                    ad.Status = AdvertStatus.Finished;
                    ad.Save();
                }
                else
                {
                    ad.SaveClicks();
                }

                AnimatedHeight = 90;
            }
        }
        else
        {
            //Non-logged in member
            //Just display 'you must login' message
            DisplayInfo(L1.YOUMUSTBELOGGED, false);
        }
        AdInfoContainer.Text = "";
    }
Beispiel #8
0
    protected UserControl GetCashLink(PtcAdvert ad)
    {
        UserControl objControl    = (UserControl)Page.LoadControl("~/Controls/Advertisements/PtcAdvert.ascx");
        var         parsedControl = objControl as IPtcAdvertObjectControl;

        parsedControl.Object = ad;
        parsedControl.DataBind();

        return(objControl);
    }
Beispiel #9
0
    protected void DirectRefsGridView_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        //We want to obey OnSort and OnChart events
        string[] commands = new string[5] {
            "start", "stop", "add", "remove", "edit"
        };

        if (commands.Contains(e.CommandName))
        {
            ErrorMessagePanel2.Visible = false;

            int         index = e.GetSelectedRowIndex() % DirectRefsGridView.PageSize;
            GridViewRow row   = DirectRefsGridView.Rows[index];
            string      AdId  = (row.Cells[1].Text.Trim());
            var         Ad    = new PtcAdvert(Convert.ToInt32(AdId));

            if (e.CommandName == "start")
            {
                //Check Max Campaign limit
                int currentCamapigns = PtcAdvert.GetUserActiveCampaignsCount(Member.CurrentId);

                if (currentCamapigns + 1 > Member.CurrentInCache.Membership.MaxActivePtcCampaignLimit)
                {
                    ErrorMessagePanel2.Visible = true;
                    ErrorMessage2.Text         = U5006.CANNOTEXCEED.Replace("%n%", Member.CurrentInCache.Membership.MaxActivePtcCampaignLimit.ToString());
                }
                else
                {
                    Ad.Status = AdvertStatus.Active;
                    Ad.SaveStatus();
                }
            }
            else if (e.CommandName == "stop")
            {
                Ad.Status = AdvertStatus.Paused;
                Ad.SaveStatus();
            }
            else if (e.CommandName == "add")
            {
                Response.Redirect("credits.aspx?id=" + AdId);
            }
            else if (e.CommandName == "remove")
            {
                Ad.Status = AdvertStatus.Deleted;
                Ad.SaveStatus();
            }
            else if (e.CommandName == "edit")
            {
                Response.Redirect("ads.aspx?editid=" + AdId);
            }

            UpdateMaxActiveCampaignsLiteralText();
            DirectRefsGridView.DataBind();
        }
    }
Beispiel #10
0
    protected UserControl GetAdHTML(PtcAdvert ad, Member user, string color = "")
    {
        bool IsActive = true;

        if (Member.IsLogged)
        {
            IsActive = !user.AdsViewed.Contains(ad.Id);
        }

        UserControl objControl    = (UserControl)Page.LoadControl("~/Controls/Advertisements/PtcAdvert.ascx");
        var         parsedControl = objControl as IPtcAdvertObjectControl;

        parsedControl.Object = ad;

        PropertyInfo myProp = parsedControl.GetType().GetProperty("IsActive");

        myProp.SetValue(parsedControl, IsActive, null);

        parsedControl.DataBind();

        return(objControl);
    }
Beispiel #11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        AccessManager.RedirectIfDisabled(AppSettings.TitanFeatures.AdvertisersRoleEnabled &&
                                         (AppSettings.TitanFeatures.AdvertAdsEnabled) &&
                                         Member.CurrentInCache.IsAdvertiser);

        int AdId = Convert.ToInt32(Request.QueryString["id"]);

        Ad = new PtcAdvert(AdId);

        //Lang & Hint
        LangAdder.Add(CreateAdButton, L1.BUY);
        TitleLabel.Text = Ad.Title;
        URLLabel.Text   = Ad.TargetUrl;

        //Get Packs
        availableOptions = TableHelper.SelectRows <PtcAdvertPack>(TableHelper.MakeDictionary("IsVisibleByMembers", true));

        if (!IsPostBack)
        {
            BindDataToDDL();
        }
    }
Beispiel #12
0
    private void BindDataCountriesToDDL()
    {
        var dictlist = GeolocationUtils.GetCountriesData();

        if (PageRequest == RequestType.Edit)
        {
            var geolocated = new Dictionary <string, string>();

            var ad = new PtcAdvert(Convert.ToInt32(ViewState["editid"]));
            if (ad.IsGeolocatedByCountry)
            {
                var countries = ad.GeolocatedCC.Split(',');
                foreach (var country in countries)
                {
                    if (string.IsNullOrEmpty(country))
                    {
                        continue;
                    }

                    var countryName = CountryManager.GetCountryName(country);
                    dictlist.Remove(countryName);

                    var geolocatedCountry = GeolocationUtils.GetCountryData(countryName);
                    geolocated.Add(geolocatedCountry.Item1, geolocatedCountry.Item2);
                }
                GeoCountries.DataSource     = geolocated;
                GeoCountries.DataTextField  = "Value";
                GeoCountries.DataValueField = "Key";
                GeoCountries.DataBind();
            }
        }
        AllCountries.DataSource     = dictlist;
        AllCountries.DataTextField  = "Value";
        AllCountries.DataValueField = "Key";
        AllCountries.DataBind();
    }
Beispiel #13
0
        public Money CreditMember(PtcAdvert Ad, bool isFromAutosurf = false)
        {
            Money Calculated = PtcAdvert.CalculateNormalMemberEarnings(User, Ad);

            base.CreditMainBalance(Calculated, "PTC", BalanceLogType.Other);

            //To not overflow the logs
            if (User.Membership.AdvertPointsEarnings > 0)
            {
                base.CreditPoints(User.Membership.AdvertPointsEarnings, "PTC", BalanceLogType.Other);
            }

            //Ad Credits?
            if (AppSettings.PtcAdverts.PTCCreditsEnabled)
            {
                User.AddToPTCCredits(User.Membership.PTCCreditsPerView, "PTC");

                //Credit advertiser
                if (Ad.Advertiser.Is(Advertiser.Creator.Member) && Ad.AdvertiserUserId != User.Id)
                {
                    Member UplineAdvertiser = new Member(Ad.AdvertiserUserId);
                    UplineAdvertiser.AddToPointsBalance(UplineAdvertiser.Membership.PointsYourPTCAdBeingViewed, "PTC Ad Viewed");
                    UplineAdvertiser.SaveBalances();
                    Ad.PointsEarnedFromViews += UplineAdvertiser.Membership.PointsYourPTCAdBeingViewed;
                    Ad.Save();
                }
            }

            //OK mark as watched and credit
            List <int> av = User.AdsViewed;

            av.Add(Ad.Id);
            User.AdsViewed  = av;
            User.LastActive = DateTime.Now;

            if (isFromAutosurf)
            {
                User.PtcAutoSurfClicksThisMonth += 1;
            }

            User.PtcSurfClicksThisMonth += 1;

            //Achievements
            User.TryToAddAchievements(
                Prem.PTC.Achievements.Achievement.GetProperAchievements(
                    Prem.PTC.Achievements.AchievementType.AfterClicks, User.TotalClicks + 1));

            Money NewTotalEarned = (User.TotalEarned + Calculated);

            User.TryToAddAchievements(
                Prem.PTC.Achievements.Achievement.GetProperAchievements(
                    Prem.PTC.Achievements.AchievementType.AfterEarning, NewTotalEarned.GetRealTotals()));

            User.IncreaseUserStatClicks(1);
            User.IncreaseStatClicks(1);
            User.IncreaseCashLinksEarnings(Calculated);

            //Slot machine chances
            SlotMachine.SlotMachine.TryAddChances(User);

            User.Save();

            //Check the contests
            Prem.PTC.Contests.ContestManager.IMadeAnAction(Prem.PTC.Contests.ContestType.Click, User.Name, null, 1);

            var rrm = new RentReferralsSystem(User.Name, User.Membership);

            rrm.IClicked(Ad);

            TryCreditDirectReferer(Ad);

            return(Calculated);
        }
Beispiel #14
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; ";
    }
Beispiel #15
0
 protected bool IsSearchRequirementsMeet(PtcAdvert ad, string text)
 {
     return(ad.Title.ToLower().Contains(text.ToLower()) || (!String.IsNullOrEmpty(ad.Description) && ad.Description.ToLower().Contains("#" + text.ToLower())));
 }
Beispiel #16
0
    protected void DirectRefsGridView_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            //The ad id [1]
            PtcAdvert Ad = new PtcAdvert(Convert.ToInt32(e.Row.Cells[1].Text));

            //Description [23]
            if (string.IsNullOrEmpty(e.Row.Cells[23].Text))
            {
                e.Row.Cells[23].Text = HtmlCreator.GetCheckboxUncheckedImage();
            }
            else
            {
                e.Row.Cells[23].Text = HtmlCreator.GetCheckboxCheckedImage();
            }

            //End mode [17]
            End.Mode Mode = (End.Mode)Convert.ToInt32(e.Row.Cells[17].Text);

            //Status [25]
            AdvertStatus Status = (AdvertStatus)Convert.ToInt32(e.Row.Cells[25].Text);
            e.Row.Cells[25].Text = HtmlCreator.GetColoredStatus(Status);

            //Pack [3]
            AdvertPack Pack = new PtcAdvertPack(Convert.ToInt32(e.Row.Cells[3].Text));

            //Displaytime [18]
            e.Row.Cells[18].Text += "s";

            //Shorten url [4]
            if (e.Row.Cells[4].Text.Length > 18)
            {
                e.Row.Cells[4].Text = e.Row.Cells[4].Text.Substring(0, 15) + "...";
            }

            //TItle [5]
            e.Row.Cells[5].Text = e.Row.Cells[5].Text.Replace("&lt;", "<");
            e.Row.Cells[5].Text = e.Row.Cells[5].Text.Replace("&gt;", ">");

            e.Row.Cells[5].Text = Ad.TargetUrl;

            string starredAd = Ad.IsStarredAd ? "<img src='Images/Misc/star.png' style='width:16px;height:16px;'> " : "";
            string targetUrl = Ad.TargetUrl.Length > 12 ? Ad.TargetUrl.Substring(0, 12) + "..." : Ad.TargetUrl;
            e.Row.Cells[5].Text = starredAd + Ad.Title + "<br/><i>" + targetUrl + "</i>";

            //Progress [11]
            e.Row.Cells[11].Text = HtmlCreator.GenerateAdProgressHTML(Ad).Replace("clicks", L1.CLICKSSMALL).Replace("days", L1.DAYS);

            //PointsEarnedFromViews [12]
            if (AppSettings.PtcAdverts.PTCCreditsEnabled)
            {
                e.Row.Cells[12].Text = string.Format("{0}/~{1}", Ad.PointsEarnedFromViews, Member.CurrentInCache.Membership.PointsYourPTCAdBeingViewed * Ad.Ends.Value);
            }
            else
            {
                e.Row.Cells[12].CssClass = "displaynone";
            }


            //Add % progress [13]
            e.Row.Cells[13].Text = Ad.ProgressInPercent.ToString() + "%";

            //Add total views [14]
            e.Row.Cells[14].Text = e.Row.Cells[15].Text;

            //Geolocation check [24]
            var check = (CheckBox)e.Row.Cells[24].Controls[0];
            if (check.Checked)
            {
                e.Row.Cells[24].Text = HtmlCreator.GetCheckboxCheckedImage();
            }
            else
            {
                e.Row.Cells[24].Text = HtmlCreator.GetCheckboxUncheckedImage();
            }

            // Start[31] Pause[32] Add [33] Remove [34]
            if (Status != AdvertStatus.Paused)
            {
                e.Row.Cells[31].Text = "&nbsp;";
            }

            if (Status != AdvertStatus.Active)
            {
                e.Row.Cells[32].Text = "&nbsp;";
            }

            if (Status != AdvertStatus.Finished)
            {
                e.Row.Cells[33].Text = "&nbsp;";
            }

            if (!Status.CanBeRemoved())
            {
                e.Row.Cells[34].Text = "&nbsp;";
            }

            //Edit button [35]
            ((LinkButton)e.Row.Cells[35].FindControl("ImageButton4")).ToolTip = U5007.EDIT;
            if (Ad.Status == AdvertStatus.Rejected)
            {
                e.Row.Cells[35].Controls.Clear();
            }
        }
        else if (e.Row.RowType == DataControlRowType.Header)
        {
            //PointsEarnedFromViews [12]
            DirectRefsGridView.Columns[12].HeaderText = string.Format(U5007.EARNED, AppSettings.PointsName);
        }

        if (!AppSettings.PtcAdverts.FeedbackCaptchaEnabled)
        {
            DirectRefsGridView.Columns[28].HeaderStyle.CssClass = "displaynone";
            DirectRefsGridView.Columns[29].HeaderStyle.CssClass = "displaynone";
            DirectRefsGridView.Columns[30].HeaderStyle.CssClass = "displaynone";
            DirectRefsGridView.Columns[28].ItemStyle.CssClass   = "displaynone";
            DirectRefsGridView.Columns[29].ItemStyle.CssClass   = "displaynone";
            DirectRefsGridView.Columns[30].ItemStyle.CssClass   = "displaynone";
        }


        if (!AppSettings.PtcAdverts.PTCCreditsEnabled)
        {
            DirectRefsGridView.Columns[12].HeaderStyle.CssClass = "displaynone";
        }
    }
Beispiel #17
0
    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;
            }
        }
    }
Beispiel #18
0
    protected void GetAdWithPrice(ref PtcAdvert Ad, ref Money AdCost, ref PtcAdvertPack Pack, bool throwExceptions = true)
    {
        try
        {
            ErrorMessagePanel.Visible = false;
            int packId = int.Parse(ddlOptions.SelectedValue);

            //Use Ad Credits only
            if (packId == -1)
            {
                Pack = null;
                if (!UseExtraViewsCheckBox.Checked && throwExceptions)
                {
                    throw new MsgException(U5006.SELECTUSEXTRAVIEWS);
                }
            }
            else
            {
                Pack = new PtcAdvertPack(packId);
            }

            AdCost = Money.Zero;

            if (Pack != null && Ad.Pack.Id != Pack.Id)
            {
                AdCost       = PtcAdvertManager.GetDiscountedPTCPackPrice(Pack);
                Ad.PackPrice = AdCost;
            }

            //Set basics
            if (AppSettings.PtcAdverts.CashLinkViewEnabled == AppSettings.PTCViewMode.CashLink)
            {
                Ad.Title = "Cash Link"; //Fixed title for cash links
            }
            else
            {
                Ad.Title = InputChecker.HtmlEncode(Title.Text, Title.MaxLength, L1.TITLE);
            }

            Ad.TargetUrl = URL.Text;

            int categoryId = -1;

            if (AppSettings.PtcAdverts.PTCCategoryPolicy == AppSettings.PTCCategoryPolicy.Custom)
            {
                int.TryParse(CategoriesDDL.SelectedValue, out categoryId);
            }

            Ad.CategoryId = categoryId;

            if (chbDescription.Checked)
            {
                if (Ad.Description == null || Ad.Description == string.Empty)
                {
                    AdCost += AppSettings.PtcAdverts.DescriptionCost;
                }

                Ad.Description = InputChecker.HtmlEncode(Description.Text, Description.MaxLength, L1.DESCRIPTION);
            }
            else
            {
                Ad.Description = string.Empty;
            }

            if (chbBold.Checked)
            {
                if (!Ad.HasBoldTitle)
                {
                    AdCost += AppSettings.PtcAdverts.FontBoldCost;
                }

                Ad.HasBoldTitle = true;
            }

            if (chbGeolocation.Checked)
            {
                if ((Ad.GeolocatedCC == null || Ad.GeolocatedCC == string.Empty) && Ad.GeolocatedAgeMin == 0 && Ad.GeolocatedAgeMax == 0 && Ad.GeolocatedGender == Gender.Null)
                {
                    AdCost += AppSettings.PtcAdverts.GeolocationCost;
                }

                //Now get it from client-state
                var CTable   = GeoCountries.Items;
                var geoUList = GeolocationUtils.GeoCountData.Keys;

                StringBuilder sb = new StringBuilder();

                foreach (ListItem item in CTable)
                {
                    if (geoUList.Contains <string>(item.Value))
                    {
                        var countryCode = CountryManager.GetCountryCode(item.Value);
                        if (!string.IsNullOrWhiteSpace(countryCode))
                        {
                            sb.Append(CountryManager.GetCountryCode(item.Value));
                            sb.Append(",");
                        }
                    }
                }

                Ad.GeolocatedCC     = sb.ToString().Trim(',');
                Ad.GeolocatedAgeMin = Convert.ToInt32(GeoAgeMin.Text);
                Ad.GeolocatedAgeMax = Convert.ToInt32(GeoAgeMax.Text);
                Ad.GeolocatedGender = (Gender)Convert.ToInt32(GeoGenderList.SelectedValue);
            }
            else
            {
                Ad.GeolocatedCC     = string.Empty;
                Ad.GeolocatedAgeMin = Ad.GeolocatedAgeMax = 0;
                Ad.GeolocatedGender = Gender.Null;
            }

            if (BackgroundColorCheckBox.Checked)
            {
                BgColorsDDL.Visible = true;
                var bgColor = new PtcAdvertBgColor(Convert.ToInt32(BgColorsDDL.SelectedValue));
                BgColorsDDL.Attributes.Add("style", string.Format("background-color:{0};color:white;", new PtcAdvertBgColor(Convert.ToInt32(BgColorsDDL.SelectedValue)).BgColor));

                if (Ad.BackgroundColor != bgColor.BgColor)
                {
                    AdCost            += bgColor.Price;
                    Ad.BackgroundColor = bgColor.BgColor;
                }
            }

            if (AppSettings.PtcAdverts.FeedbackCaptchaEnabled)
            {
                Ad.CaptchaQuestion = InputChecker.HtmlEncode(CaptchaQuestionTexbox.Text, CaptchaQuestionTexbox.MaxLength, U6013.YESNOCAPTCHAQUESTION);
            }

            if (AppSettings.PtcAdverts.StarredAdsEnabled && StarredAdCheckBox.Checked)
            {
                if (!Ad.IsStarredAd)
                {
                    AdCost += AppSettings.PtcAdverts.StarredAdsPrice;
                }

                Ad.IsStarredAd = true;
            }

            if (AppSettings.PtcAdverts.PTCImagesEnabled)
            {
                Ad.ImagePath = PTCImage_Image.DescriptionUrl;
            }
            else
            {
                Ad.ImagePath = null;
            }
        }
        catch (MsgException ex)
        {
            ErrorMessagePanel.Visible = true;
            ErrorMessage.Text         = ex.Message;
        }
    }
Beispiel #19
0
    private static int RefreshAndGetValue(NotificationType type, Member user = null)
    {
        if (!Member.IsLogged)
        {
            return(0);
        }

        if (user == null)
        {
            user = Member.CurrentInCache;
        }

        switch (type)
        {
        case NotificationType.NewAds:

            List <PtcAdvert> AvailableAdList = PtcAdvert.GetActiveAdsForUser(user);
            int newAdsCounter = 0;

            foreach (PtcAdvert Ad in AvailableAdList)
            {
                if (!user.AdsViewed.Contains(Ad.Id))
                {
                    newAdsCounter++;
                }
            }
            return(newAdsCounter);

        case NotificationType.NewMessages:
            return(ConversationMessage.GetNumberOfUnreadMessages(Member.CurrentId));

        case NotificationType.NewDirectReferrals:

            using (var bridge = ParserPool.Acquire(Database.Client))
            {
                return((int)bridge.Instance.ExecuteRawCommandScalar("SELECT COUNT (*) FROM Users WHERE IsSpotted = 0 AND ReferrerId = "
                                                                    + Member.CurrentId));
            }

        case NotificationType.NewAchievements:

            return(user.UnspottedAchievements);

        case NotificationType.NewCPAOffers:
            //CPAOFfers
            //User is already loaded
            var OM = new OffersManager(user);
            return(OM.AllActiveOffersForMember.Count);

        case NotificationType.UnreadSupportTickets:

            return((int)TableHelper.SelectScalar(String.Format("SELECT COUNT(*) FROM SupportTickets WHERE IsRead = 0 AND FromUsername = '******'",
                                                               Member.CurrentName)));


        case NotificationType.NewAdPacksAds:

            List <AdPacksAdvert> AdPacksAdList = AdPackManager.GetAdPacksAdvertsForUsers(user.Membership.AdPackDailyRequiredClicks);
            int numberofAdsViewed = user.RSAPTCAdsViewed.Count();

            int adsRequiredToWatch = user.Membership.AdPackDailyRequiredClicks - numberofAdsViewed;

            if (adsRequiredToWatch <= 0)
            {
                return(0);
            }

            if (adsRequiredToWatch > AdPacksAdList.Count)
            {
                int adCount = 0;
                foreach (AdPacksAdvert ad in AdPacksAdList)
                {
                    if (!user.RSAPTCAdsViewed.Contains(ad.Id))
                    {
                        adCount++;
                    }
                }
                return(adCount);
            }
            return(adsRequiredToWatch);

        case NotificationType.UnassignedMatrixMembers:
            return(user.GetUnassignedMatrixMembersCount());

        case NotificationType.PendingRepresentativePaymentRequest:
            return(ConversationMessage.GetPendingRequestForRepresentativeCount(user.Id));

        default:
            return(0);
        }
    }
Beispiel #20
0
    protected void RefreshAdvertAndPrice(object sender, EventArgs e)
    {
        PtcAdvert Ad;

        if (PageRequest == RequestType.Edit)
        {
            int adId = Convert.ToInt32(ViewState["editid"]);
            Ad = new PtcAdvert(adId);
        }
        else
        {
            Ad = new PtcAdvert();
        }

        Money         AdCost = Money.Zero;
        PtcAdvertPack Pack   = new PtcAdvertPack();

        GetAdWithPrice(ref Ad, ref AdCost, ref Pack, false);

        if (AppSettings.PtcAdverts.CashLinkViewEnabled == AppSettings.PTCViewMode.CashLink)
        {   //CashLink
            titleTr.Visible       = false;
            descriptionTr.Visible = false;
            boldTr.Visible        = false;
            BuyWithPTCCreditsPlaceHolder.Visible = false;
            Abox1.Visible = true;
        }

        Abox1.IsActive = true;
        Abox1.Object   = Ad;
        Abox1.DataBind();

        Money totalCost = AdCost;// - Ad.Price;

        lblPrice.Text = (totalCost < Money.Zero ? Money.Zero : totalCost).ToString();

        if (AppSettings.PtcAdverts.AdvertPTCPackCashbackEnabled)
        {
            if (Pack.PTCPackCashBackPercent != 0)
            {
                Double CashBack = Double.Parse(totalCost.ToClearString()) * ((Double)Pack.PTCPackCashBackPercent / 100.0);
                CashBackLabel.Text = new Money(CashBack).ToString();
            }
            else
            {
                CashBackLabel.Text = U6010.NOCASHBACK;
            }
        }

        if (Pack != null && Pack.Ends.EndMode == End.Mode.Days)
        {
            TotalViewsPlaceHolder.Visible = false;
        }
        else
        {
            TotalViewsPlaceHolder.Visible = true;

            var totalViews    = string.Empty;
            var totalViewsInt = 0;

            if (Pack != null && Pack.Ends.EndMode == End.Mode.Clicks)
            {
                totalViews    += Pack.Ends.Value;
                totalViewsInt += (int)Pack.Ends.Value;
            }

            if (AppSettings.PtcAdverts.PTCCreditsEnabled && UseExtraViewsCheckBox.Checked)
            {
                int ptcCreditViews = 0;
                if (int.TryParse(PTCCreditsTextBox.Text, out ptcCreditViews))
                {
                    totalViews    += " + " + PTCCreditsTextBox.Text;
                    totalViewsInt += ptcCreditViews;
                }
            }

            lblViews.Text = totalViews;
            totalViewsInt = totalViewsInt - Ad.Clicks;

            if (totalViewsInt < 0)
            {
                totalViewsInt = 0;
            }

            lblTotalViews.Text = string.Format("{0} = {1}", U5008.TOTALVIEWSDESC.ToLower(), totalViewsInt);
        }
    }
Beispiel #21
0
        private void TryCreditDirectReferer(PtcAdvert ad)
        {
            if (!User.HasReferer || TitanFeatures.IsGambinos && User.MembershipId == 1)
            {
                return;
            }

            Member referer = new Member(User.ReferrerId);

            if (referer.IsRented)
            {
                return;
            }

            if (referer.HasClickedEnoughToProfitFromReferrals())
            {
                Money amountToCredit = PtcAdvert.CalculateEarningsFromDirectReferral(referer.Membership, ad);

                if (AppSettings.Payments.CommissionBalanceEnabled)
                {
                    referer.AddToCommissionBalance(amountToCredit, "PTC /ref/" + User.Name, BalanceLogType.Other);
                }
                else
                {
                    referer.AddToMainBalance(amountToCredit, "PTC /ref/" + User.Name, BalanceLogType.Other);
                }

                referer.IncreaseEarnings(amountToCredit);
                referer.IncreaseEarningsFromDirectReferral(amountToCredit);
                referer.IncreaseDRClicks();
                referer.IncreaseStatClicks(1);
                referer.IncreaseDRCashLinksEarnings(amountToCredit);

                referer.StatsCommissionsCurrentWeekIncome  += amountToCredit;
                referer.StatsCommissionsCurrentMonthIncome += amountToCredit;

                var pointsEarnings = referer.Membership.DirectReferralAdvertClickEarningsPoints;
                referer.AddToPointsBalance(pointsEarnings, "PTC /ref/" + User.Name);
                referer.IncreaseDirectRefPointsEarnings(pointsEarnings);
                referer.IncreasePointsEarnings(pointsEarnings);

                User.TotalPTCClicksToDReferer    += 1;
                User.TotalEarnedToDReferer       += amountToCredit;
                User.LastDRActivity               = AppSettings.ServerTime;
                User.TotalPointsEarnedToDReferer += pointsEarnings;
                User.SaveStatisticsAndBalances();

                bool isFullSaveRequired1 = false;
                bool isFullSaveRequired2 = false;

                //Achievements trial
                isFullSaveRequired1 = referer.TryToAddAchievements(
                    Prem.PTC.Achievements.Achievement.GetProperAchievements(
                        Prem.PTC.Achievements.AchievementType.AfterClicks, referer.TotalClicks + 1));

                string  inter     = (referer.TotalEarned + amountToCredit).ToClearString();
                Decimal tempMoney = Decimal.Parse(inter, new System.Globalization.CultureInfo("en-US"));

                isFullSaveRequired2 = referer.TryToAddAchievements(
                    Prem.PTC.Achievements.Achievement.GetProperAchievements(
                        Prem.PTC.Achievements.AchievementType.AfterEarning, Convert.ToInt32(tempMoney)));

                if (isFullSaveRequired1 || isFullSaveRequired2)
                {
                    referer.Save();
                }
                else
                {
                    referer.SaveStatisticsAndBalances();
                }
            }
        }
Beispiel #22
0
        private void HandleOwnerUser(Member OwnerUser, PtcAdvert Ad, bool FiredByDirectReferral = false, Member WhoFired = null)
        {
            bool CreditMoney = OwnerUser.HasClickedEnoughToProfitFromReferrals();

            //Check if earning only from Standard and Extended is enabled
            //TO REMOVE
            if (CreditMoney && AppSettings.Misc.ExposureRefEarningsEnabled)
            {
                if (Ad.ExposureType == AdExposure.Standard || Ad.ExposureType == AdExposure.Extended)
                {
                    CreditMoney = true;
                }
                else
                {
                    CreditMoney = false;
                }
            }

            if (CreditMoney)
            {
                var Earnings = FiredByDirectReferral ? PtcAdvert.CalculateEarningsFromDirectReferral(OwnerUser, Ad) : PtcAdvert.CalculateEarningsFromRentedReferral(OwnerUser, Ad);

                if (FiredByDirectReferral)
                {
                    OwnerUser.AddToMainBalance(Earnings, "PTC /ref/" + Username, BalanceLogType.Other);
                }
                else
                {
                    OwnerUser.AddToMainBalance(Earnings, "PTC /ref/", BalanceLogType.Other);
                }

                bool isFullSaveRequired1 = false;
                bool isFullSaveRequired2 = false;

                //Achievements trial
                isFullSaveRequired1 = OwnerUser.TryToAddAchievements(
                    Prem.PTC.Achievements.Achievement.GetProperAchievements(
                        Prem.PTC.Achievements.AchievementType.AfterClicks, OwnerUser.TotalClicks + 1));

                string  inter     = (OwnerUser.TotalEarned + Earnings).ToClearString();
                Decimal tempMoney = Decimal.Parse(inter, new System.Globalization.CultureInfo("en-US"));


                isFullSaveRequired2 = OwnerUser.TryToAddAchievements(
                    Prem.PTC.Achievements.Achievement.GetProperAchievements(
                        Prem.PTC.Achievements.AchievementType.AfterEarning, Convert.ToInt32(tempMoney)));

                OwnerUser.IncreaseEarnings(Earnings);
                OwnerUser.IncreaseStatClicks(1);

                if (FiredByDirectReferral)
                {
                    var pointsEarnings = OwnerUser.Membership.DirectReferralAdvertClickEarningsPoints;
                    OwnerUser.AddToPointsBalance(pointsEarnings, "PTC /ref/" + Username);
                    OwnerUser.IncreaseDRClicks();
                    OwnerUser.IncreaseEarningsFromDirectReferral(Earnings);
                    if (WhoFired != null)
                    {
                        WhoFired.TotalPTCClicksToDReferer += 1;
                        WhoFired.TotalEarnedToDReferer    += Earnings;
                        WhoFired.SaveStatisticsAndBalances();
                    }
                }
                else
                {
                    OwnerUser.IncreaseRRClicks();
                }

                if (isFullSaveRequired1 || isFullSaveRequired2)
                {
                    OwnerUser.Save();
                }
                else
                {
                    OwnerUser.SaveStatisticsAndBalances();
                }
            }
            else
            {
                OwnerUser.IncreaseStatClicks(1);

                if (FiredByDirectReferral)
                {
                    var Earnings = PtcAdvert.CalculateEarningsFromDirectReferral(OwnerUser, Ad);
                    OwnerUser.AddToMainBalance(Earnings, "PTC /ref/" + Username, BalanceLogType.Other);
                    OwnerUser.IncreaseEarnings(Earnings);

                    var pointsEarnings = OwnerUser.Membership.DirectReferralAdvertClickEarningsPoints;
                    OwnerUser.AddToPointsBalance(pointsEarnings, "PTC /ref/" + Username);
                    OwnerUser.IncreaseDRClicks();
                    OwnerUser.TotalEarned += Earnings;

                    if (WhoFired != null)
                    {
                        WhoFired.TotalPTCClicksToDReferer += 1;
                        WhoFired.TotalEarnedToDReferer    += Earnings;
                        WhoFired.LastDRActivity            = AppSettings.ServerTime;
                        WhoFired.SaveStatisticsAndBalances();
                    }
                }
                else
                {
                    OwnerUser.IncreaseRRClicks();
                }

                OwnerUser.SaveStatisticsAndBalances();
            }
        }
Beispiel #23
0
    protected void CreateAdButton_Click(object sender, EventArgs e)
    {
        ErrorMessagePanel.Visible = false;
        SuccMessagePanel.Visible  = false;

        if (Page.IsValid)
        {
            try
            {
                AppSettings.DemoCheck();
                Member User      = null;
                int    oldPackId = 0;

                if (Member.IsLogged)
                {
                    User = Member.Logged(Context);
                }

                if (URL.Enabled)
                {
                    throw new MsgException(U4200.CHECKURL);
                }

                PtcAdvert Ad;
                if (PageRequest == RequestType.Edit)
                {
                    int adId = Convert.ToInt32(ViewState["editid"]);
                    Ad        = new PtcAdvert(adId);
                    oldPackId = Ad.Pack.Id;
                }
                else
                {
                    Ad = new PtcAdvert();
                }

                Money         AdCost = Money.Zero;
                PtcAdvertPack Pack   = new PtcAdvertPack();

                GetAdWithPrice(ref Ad, ref AdCost, ref Pack);

                //Add the ad to the db (for approval)
                Ad.Price = AdCost;
                if (Pack != null)
                {
                    Ad.Pack = Pack;
                }

                if (Member.IsLogged)
                {
                    //Take money and save the user
                    int adViews = 0;
                    if (AppSettings.PtcAdverts.PTCCreditsEnabled && UseExtraViewsCheckBox.Checked)
                    {
                        adViews = Convert.ToInt32(PTCCreditsTextBox.Text);
                        if (adViews < 0)
                        {
                            throw new MsgException("Input cannot be negative.");
                        }

                        decimal adCreditsSpent       = 0;
                        var     creditsPerDayOrClick = 0m;
                        if (Pack == null)
                        {
                            if (TitanFeatures.isSatvetErturkmen)
                            {
                                PtcAdvertPack advertPack = TableHelper.GetListFromRawQuery <PtcAdvertPack>("SELECT TOP 1 * FROM PtcAdvertPacks")[0];
                                Ad.Pack = advertPack;
                                Ad.Ends = End.FromClicks(adViews);
                                creditsPerDayOrClick = advertPack.PTCCreditsPerDayOrClick;
                            }
                        }
                        else
                        {
                            Ad.Ends = Ad.Ends.AddValue(adViews);
                            creditsPerDayOrClick = Pack.PTCCreditsPerDayOrClick;
                        }

                        if (PageRequest == RequestType.Edit && Ad.ExtraViews != -1)
                        {
                            adCreditsSpent = (adViews - Ad.ExtraViews) * creditsPerDayOrClick;
                            if (adCreditsSpent < 0)
                            {
                                adCreditsSpent = 0;
                            }
                        }
                        else
                        {
                            adCreditsSpent = adViews * creditsPerDayOrClick;
                        }

                        Ad.ExtraViews = adViews;

                        if (adCreditsSpent > Member.Current.PTCCredits)
                        {
                            throw new MsgException(U5006.NOTENOUGHADCREDITS);
                        }
                        else
                        {
                            User.SubstractFromPTCCredits(adCreditsSpent, "PTC advert");
                        }
                    }
                    else
                    {
                        Ad.ExtraViews = -1;
                    }

                    if (PageRequest == RequestType.Edit)
                    {
                        Ad.IsEdited = true;
                    }

                    Ad.TargetBalance = TargetBalanceRadioButtonList.TargetBalance;
                    PurchaseOption.ChargeBalance(User, AdCost, TargetBalanceRadioButtonList.Feature, Ad.TargetBalance, PageRequest == RequestType.Edit ? "PTC update" : "PTC advert");

                    Ad.Advertiser       = Advertiser.AsMember(User.Name);
                    Ad.AdvertiserUserId = User.Id;
                    Ad.Status           = AdvertStatusExtensions.GetStartingStatus();

                    if (AppSettings.PtcAdverts.AdvertPTCPackCashbackEnabled && Pack.PTCPackCashBackPercent != 0)
                    {
                        Money CashBack = new Money(Double.Parse(AdCost.ToClearString()) * ((Double)Pack.PTCPackCashBackPercent / 100.0));
                        User.AddToTrafficBalance(CashBack, U6010.PTCCASHBACK);
                        User.Save();
                    }
                }
                else
                {
                    Ad.Advertiser    = Advertiser.AsStranger(OutEmail.Text);
                    Ad.TargetBalance = PurchaseBalances.PaymentProcessor;
                    Ad.Status        = AdvertStatus.Null;
                }

                if (oldPackId != 0 && oldPackId != Ad.Pack.Id)
                {
                    Ad.ResetClicks();
                }

                Ad.Save();

                if (Member.IsLogged)
                {
                    //Achievements trial
                    int  UserCurrentCampaigns = TableHelper.CountOf <PtcAdvert>(TableHelper.MakeDictionary("CreatorUsername", User.Name));
                    bool ShouldBeSaved        = User.TryToAddAchievements(
                        Prem.PTC.Achievements.Achievement.GetProperAchievements(
                            Prem.PTC.Achievements.AchievementType.AfterAdvertisingPtcCampaigns, UserCurrentCampaigns));

                    if (ShouldBeSaved)
                    {
                        User.Save();
                    }

                    if (PageRequest == RequestType.Edit)
                    {
                        History.AddEdit(User.Name, AdCost, "Advert campaign");
                    }
                    else
                    {
                        History.AddPurchase(User.Name, AdCost, "Advert campaign");

                        MatrixBase.TryAddMemberAndCredit(User, AdCost, AdvertType.PTC);
                    }

                    if (Ad.Status != AdvertStatus.WaitingForAcceptance)
                    {
                        PtcCrediter.TryToCreditReferrerAfterPurchase(User, AdCost, PageRequest == RequestType.Edit ? "PTC update" : "PTC advert");
                    }

                    Title.Text                      = "";
                    URL.Text                        = "";
                    chbDescription.Checked          = false;
                    chbGeolocation.Checked          = false;
                    chbBold.Checked                 = false;
                    BackgroundColorCheckBox.Checked = false;
                    StarredAdCheckBox.Checked       = false;

                    SuccMessagePanel.Visible = true;

                    if (PageRequest == RequestType.Edit)
                    {
                        SuccMessage.Text = Ad.Status == AdvertStatus.WaitingForAcceptance ? U6012.EDITEDADAWAITSAPPROVAL : U6012.ADUPDATED;
                    }
                    else
                    {
                        SuccMessage.Text = Ad.Status == AdvertStatus.WaitingForAcceptance ? U4200.ADAWAITSAPPROVAL : U3501.ADCREATED;
                    }
                }
                else
                {
                    //Show buttons
                    PaymentButtons.Visible = true;
                    CreateAdButton.Visible = false;

                    PaymentButtons.Text = GenerateHTMLButtons.GetPaymentButtons(new BuyAdvertButtonGenerator <IPtcAdvertPack>(Ad));
                }

                ViewState["editid"] = null;
            }
            catch (MsgException ex)
            {
                ErrorMessagePanel.Visible = true;
                ErrorMessage.Text         = ex.Message;
            }
            catch (Exception ex)
            {
                ErrorLogger.Log(ex);
            }
        }
    }
Beispiel #24
0
    public override void DataBind()
    {
        base.DataBind();

        if (Member.IsLogged)
        {
            Member user = Member.CurrentInCache;

            UserEarnedMoney   = PtcAdvert.CalculateNormalMemberEarnings(user, Object);
            EarningsDR        = PtcAdvert.CalculateEarningsFromDirectReferral(user, Object);
            EarningsRR        = PtcAdvert.CalculateEarningsFromRentedReferral(user, Object);
            EarningsPoints    = user.Membership.AdvertPointsEarnings;
            EarningsAdCredits = user.Membership.PTCCreditsPerView;
        }
        else
        {
            //Public ad view
            UserEarnedMoney   = PtcAdvert.CalculateNormalMemberEarnings(Membership.Standard, Object);
            EarningsDR        = PtcAdvert.CalculateEarningsFromDirectReferral(Membership.Standard, Object);
            EarningsRR        = PtcAdvert.CalculateEarningsFromRentedReferral(Membership.Standard, Object);
            EarningsPoints    = Membership.Standard.AdvertPointsEarnings;
            EarningsAdCredits = Membership.Standard.PTCCreditsPerView;
        }

        //Display PTC Advert Type
        if (AppSettings.PtcAdverts.CashLinkViewEnabled == AppSettings.PTCViewMode.PTC)
        {
            //Starred Ads
            if (Object.IsStarredAd)
            {
                starImg.Visible  = true;
                starImg2.Visible = true;
            }
            else
            {
                starImg.Visible  = false;
                starImg2.Visible = false;
            }

            //Favorite Ads
            if (AppSettings.PtcAdverts.FavoriteAdsEnabled && Member.IsLogged &&
                FavoriteAd.IsFavorite(Member.CurrentId, Object.Id, FavoriteAdType.PTC))
            {
                favoriteImg.Visible  = true;
                favoriteImg2.Visible = true;
                FavoriteCssClass     = " fav";
            }
            else
            {
                favoriteImg.Visible  = false;
                favoriteImg2.Visible = false;
            }

            if (IsActive)
            {
                ActiveAdvertPlaceHolder.Visible = true;
            }
            else
            {
                InactiveAdvertPlaceHolder.Visible = true;
            }

            if (ImageUrl != null)
            {
                //    PtcImage.ImageUrl = PtcImage2.ImageUrl = ImageUrl;
                ImageBackgroundStyle = "background: url(" + ResolveUrl(ImageUrl) + ");";
            }


            if (AppSettings.PtcAdverts.PTCImagesEnabled)
            {
                ImageClass = "has-image";
            }
            else
            {
                ImageClass = "";
            }

            CashLinkPlaceHolder.Visible = false;
        }
        //Display Cash Links Advert Type
        else if (AppSettings.PtcAdverts.CashLinkViewEnabled == AppSettings.PTCViewMode.CashLink)
        {
            ActiveAdvertPlaceHolder.Visible   = false;
            InactiveAdvertPlaceHolder.Visible = false;
            if (IsActive)
            {
                CashLinkPlaceHolder.Visible = true;
            }
            else
            {
                CashLinkPlaceHolderInActive.Visible = true;
            }

            if (IsPreview) //Preview fix
            {
                CashLinkDiv.Attributes["class"] = "Abox CashLinkBox";
            }
        }
    }
Beispiel #25
0
    private void BindEditWindow()
    {
        if (!Member.IsLogged)
        {
            return;
        }

        MenuMultiView.SetActiveView(View1);
        int adId = Convert.ToInt32(ViewState["editid"]);

        EditId = "?editid=" + adId.ToString();

        PtcAdvert ad = new PtcAdvert(adId);

        if (ad.AdvertiserUserId != Member.CurrentId || ad.Status == AdvertStatus.Rejected)
        {
            Response.Redirect("~/default.aspx");
        }
        Title.Text = ad.Title;
        URL.Text   = ad.TargetUrl;

        if (AppSettings.PtcAdverts.PTCCategoryPolicy == AppSettings.PTCCategoryPolicy.Custom)
        {
            if (PtcAdvertCategory.GetActiveCategories().Any(x => x.Id == ad.CategoryId))
            {
                CategoriesDDL.SelectedValue = ad.CategoryId.ToString();
            }
        }

        var where = TableHelper.MakeDictionary("IsVisibleByMembers", true);

        if (AppSettings.PtcAdverts.PTCCreditsEnabled)
        {
            where["EndMode"] = (int)End.Mode.Clicks;
        }

        var listPacks = TableHelper.SelectRows <PtcAdvertPack>(where);

        if (listPacks.Any(x => x.Id == ad.Pack.Id))
        {
            ddlOptions.SelectedValue = ad.Pack.Id.ToString();
        }

        chbDescription.Checked = !string.IsNullOrEmpty(ad.Description);
        Description.Visible    = chbDescription.Checked;

        if (chbDescription.Checked)
        {
            Description.Text = ad.Description;
        }
        else
        {
            Description.Text = string.Empty;
        }

        chbGeolocation.Checked = ad.IsGeolocated;

        if (ad.IsGeolocatedByAge)
        {
            GeoAgeMin.Text = ad.GeolocatedAgeMin.ToString();
            GeoAgeMax.Text = ad.GeolocatedAgeMax.ToString();
        }

        if (ad.IsGeolocatedByGender)
        {
            GeoGenderList.SelectedValue = ((int)ad.GeolocatedGender).ToString();
        }

        chbBold.Checked           = ad.HasBoldTitle;
        StarredAdCheckBox.Checked = ad.IsStarredAd;

        var activeColors = PtcAdvertBgColor.GetActiveBgColors();

        if (activeColors.Any(x => x.BgColor == ad.BackgroundColor))
        {
            BgColorsDDL.SelectedValue = activeColors.Where(x => x.BgColor == ad.BackgroundColor).ToList()[0].Id.ToString();
        }

        var freeBgColors = activeColors.Where(x => x.Price == Money.Zero);

        BackgroundColorCheckBox.Checked = !freeBgColors.Any(x => x.BgColor == ad.BackgroundColor);

        CaptchaQuestionCheckBox.Checked = ad.CaptchaQuestion != AppSettings.PtcAdverts.PTCDefaultCaptchaQuestion;
        CaptchaQuestionTexbox.Visible   = CaptchaQuestionCheckBox.Checked;
        CaptchaQuestionTexbox.Text      = ad.CaptchaQuestion;

        if (ad.ExtraViews != -1)
        {
            BuyWithPTCCreditsPlaceHolder2.Visible = UseExtraViewsCheckBox.Checked = true;
            PTCCreditsTextBox.Text = ad.ExtraViews.ToString();
        }

        if (ad.ImagePath != null)
        {
            PTCImage_Image.ImageUrl = ad.ImagePath;
        }
    }