protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["id"] != null) { var te = new Encryption(); int BannerId = te.DecryptBannerId(Request.Params["id"]); BannerAdvert banner = new BannerAdvert(BannerId); var list = getWatchedBannersCollection(); if (!list.Contains(BannerId) && !AppSettings.BannerAdverts.ImpressionsEnabled) { banner.Click(); list.Add(banner.Id); saveWatchedBannersCollection(list); } Response.Redirect(banner.TargetUrl); } else if (Request.QueryString["redirect"] != null) { string redirect = Request.QueryString["redirect"]; Response.Redirect("~/" + redirect); } else if (Request.QueryString["rid"] != null) { //RSA ads var te = new Encryption(); int BannerId = te.DecryptBannerId(Request.Params["rid"]); AdPacksAdvert banner = new AdPacksAdvert(BannerId); Response.Redirect(banner.TargetUrl); } }
public static Control GetBanner(BannerAdvertDimensions dimensions, Page page, int position = 1) { allBanners = TryGetFromCache(dimensions, page, position); List <BannerAdvert> allBannersFiltered = new List <BannerAdvert>(); if (AppSettings.BannerAdverts.AdvertisingPolicy == BannerPolicy.SellingPackages) { Member User = null; if (Member.IsLogged) { User = Member.CurrentInCache; } foreach (var elem in allBanners) { if (!elem.IsGeolocated) { allBannersFiltered.Add(elem); } else if (elem.IsGeolocated && Member.IsLogged && elem.BannedCountries.Contains(User.Country)) { allBannersFiltered.Add(elem); } } } else { allBannersFiltered = allBanners; //No geolocation in Banner Bidding } _workingBanner = new HyperLink(); int bannerIndex = random.Next(0, allBannersFiltered.Count); _workingBanner = (HyperLink)GetPanelWithDimensionsAndBorder(dimensions, _workingBanner); if (allBannersFiltered.Count > 0) { BannerAdvert ChoosenBanner = allBannersFiltered[bannerIndex]; var te = new Encryption(); HttpContext.Current.Session["SurfBannerAdvertID"] = ChoosenBanner.Id; if (ChoosenBanner.ShouldBeFinished) { ChoosenBanner.Status = AdvertStatus.Finished; ChoosenBanner.SaveStatus(); } if (AppSettings.BannerAdverts.ImpressionsEnabled) { //Count impression ChoosenBanner.Click(); } //Dynamic banner (HTML code instead of image) if (ChoosenBanner.IsDynamic) { Panel panel = new Panel(); panel = (Panel)GetPanelWithDimensionsAndBorder(dimensions, panel); Literal literal = new Literal(); literal.Text = ChoosenBanner.BannerHTML; panel.Controls.Add(literal); return(panel); } dimensions = ChoosenBanner.Dimensions; var Helper = new BannerDisplayerHelper(dimensions); //Now lets create Image Web Control and return it _workingBanner.Target = "_blank"; _workingBanner.NavigateUrl = AppSettings.Site.Url + "link.aspx?id=" + te.EncryptBannerId(ChoosenBanner.Id); _workingBanner.Controls.Clear(); _workingBanner.Controls.Add(Helper.GetBannerImage(ChoosenBanner)); } return(_workingBanner); }