protected void Page_Load(object sender, EventArgs e) { AccessManager.RedirectIfDisabled(AppSettings.TitanFeatures.ReferralsRentedEnabled); Member User = Member.Current; RentReferralsSystem rrs; //For Chrome compatibility Context.Response.AppendHeader("X-XSS-Protection", "0"); //Lets check if user clicked the pack and want to make a purchase if (Request.Params.Get("__PACKID") != null && IsParameterANumber() && !AppSettings.Site.TrafficExchangeMod) { SuccMessagePanel.Visible = false; ErrorMessagePanel.Visible = false; int packID = Int32.Parse(Request.Params.Get("__PACKID")); rrs = new RentReferralsSystem(User.Name, User.Membership); try { AppSettings.DemoCheck(); ReferralPackage pack = new ReferralPackage(packID); // Check if all valid HasValidRequirements(User, pack, rrs, true); //Purchase the pack and save the user rrs.RentReferrals(pack.RefsInPackage); //throws MsgException if no ref available Money totalPrice = CalculatePackCost(User, pack); User.SubtractFromPurchaseBalance(totalPrice, "Ref: rent"); User.LastRentDate = DateTime.Now; //Check if achievement should be applied rrs = new RentReferralsSystem(User.Name, User.Membership); User.TryToAddAchievements( Prem.PTC.Achievements.Achievement.GetProperAchievements( Prem.PTC.Achievements.AchievementType.AfterHavingRentedReferrals, rrs.GetUserRentedReferralsCount())); User.Save(); // 4. Write success info SuccMessagePanel.Visible = true; SuccMessage.Text = U3501.REFSUCC; //Ad history entry History.AddPurchase(User.Name, totalPrice, pack.RefsInPackage.ToString() + " rented referrals"); } catch (MsgException ex) { ErrorMessagePanel.Visible = true; ErrorMessage.Text = ex.Message; } } //Lang DirectRefsGridView.EmptyDataText = L1.NORENTEDREFERRALS; LangAdder.Add(Button1, L1.MANAGE); LangAdder.Add(Button2, L1.RENTNEW); UserName.Text = Member.CurrentName; RemoveButton.Text = L1.REMOVE; RecycleButton.Text = string.Format("{0} ({1} {2})", L1.RECYCLE, User.Membership.RentedReferralRecycleCost, U6011.PERONE); AutopayAllOnButton.Text = AutopayOnButton.Text = U6004.AUTOPAYON; AutopayAllOffButton.Text = AutopayOffButton.Text = U6004.AUTOPAYOFF; RenewButton.Text = L1.RENEW; //Data rrs = new RentReferralsSystem(User.Name, User.Membership); RefLimit.Text = User.Membership.RentedReferralsLimit.ToString(); MaxRefPack.Text = User.Membership.MaxRefPackageCount.ToString(); RefCount.Text = rrs.GetUserRentedReferralsCount().ToString(); RentalTimeLabel.Text = AppSettings.RentedReferrals.CanBeRentedFor.Days.ToString(); RefGauranteeLabel.Text = (AppSettings.RentedReferrals.MinLastClickingActivity == TimeSpan.MinValue) ? L1.NONE : L1.CLICKEDINLAST + " " + AppSettings.RentedReferrals.MinLastClickingActivity.Days.ToString() + " " + L1.DAYS; MinClicksLabel.Text = AppSettings.Referrals.MinTotalClicksToRentRefs.ToString(); LastRentedLiteral.Text = (User.LastRentDate == null) ? L1.NEVER : User.LastRentDate.ToString(); MinRentInterval.Text = User.Membership.MinRentingInterval.Days.ToString(); TotalClicksLiteral.Text = User.TotalClicks.ToString(); //Autopay available? AutopayOnButton.Visible = AutopayOffButton.Visible = User.Membership.CanAutoPay && AppSettings.Referrals.RentedRefAutopayPolicy == AppSettings.Referrals.AutopayPolicy.UserChooses; AutopayAllPlaceHolder.Visible = User.Membership.CanAutoPay && AppSettings.Referrals.RentedRefAutopayPolicy == AppSettings.Referrals.AutopayPolicy.AllReferrals; //Generate pack images RefBoxesLiteral.Text = string.Empty; var packList = TableHelper.SelectAllRows <ReferralPackage>(); packList.Sort(Comparison); for (int i = 0; i < packList.Count; ++i) { bool isActive = HasValidRequirements(User, packList[i], rrs, false); Money packPrice = CalculatePackCost(User, packList[i]); RefBoxesLiteral.Text += HtmlCreator.GenerateRentRefBox(packList[i].RefsInPackage, packPrice, isActive, packList[i].Id); } if (AppSettings.Referrals.Renting == AppSettings.Referrals.RentingOption.DirectReferrals) { InfoPlaceHolder.Visible = false; Button1.Visible = false; Button2.CssClass = "ViewSelected"; MenuMultiView.ActiveViewIndex = 1; } //Warning displays if (!User.HasClickedEnoughToProfitFromReferrals() && DirectRefsGridView.Rows.Count != 0) { WarningPanel.Visible = true; WarningLiteral.Text = L1.REFNOPROFITS; WarningLiteral.Text = WarningLiteral.Text.Replace("%n%", AppSettings.Referrals.MinDailyClicksToEarnFromRefs.ToString()); } RemoveButton.Visible = AppSettings.RentedReferrals.IsDeletingEnabled; RecycleButton.Visible = AppSettings.RentedReferrals.IsRecyclingEnabled; RegisterStartupGridViewCode(DirectRefsGridView, SelectedPanel, ref jsSelectAllCode); }