protected void UrlCheck_ServerValidate(object source, ServerValidateEventArgs args) { // Retrieve the story given the url Dal.Story story = Incremental.Kick.Dal.Story.FetchStoryByUrl(args.Value); // If the story already exists in the database if (story != null) { // Make page invalid args.IsValid = false; // Let user kick the existing story by providing a link to it UrlCheck.ErrorMessage = string.Format("The story already exists. You might want to <a href=\"{0}\">kick it</a> instead.<br/>", UrlFactory.CreateUrl(UrlFactory.PageName.ViewStory, story.StoryIdentifier, story.Category.CategoryIdentifier)); return; } // check to see its bannination status bool banninated = BannedUrlHelper.IsUrlBanninated(args.Value, HostCache.GetHost(HostHelper.GetHostAndPort(Request.Url)).HostID); // If the url matches if (banninated) { // Make page invalid args.IsValid = false; // Let user kick the existing story by providing a link to it UrlCheck.ErrorMessage = "This URL cannot be submitted.<br/>"; } }
protected void Page_Load(object sender, EventArgs e) { if (!KickPage.KickUserProfile.IsVetted) { Response.Redirect(UrlFactory.CreateUrl(UrlFactory.PageName.UserTest, KickPage.KickUserProfile.Username)); } if (!Page.IsPostBack) { // In case a url is passed on the querystring check if the story // already exists and in that case redirect the user to the story page string url = Request.QueryString["url"]; if (!string.IsNullOrEmpty(url)) { Dal.Story story = Incremental.Kick.Dal.Story.FetchStoryByUrl(url.Trim()); if (story != null) { Response.Redirect( UrlFactory.CreateUrl(UrlFactory.PageName.ViewStory, story.StoryIdentifier, story.Category.CategoryIdentifier), true); } } // Bind list of categories Category.DataSource = CategoryCache.GetCategories(KickPage.HostProfile.HostID); Category.DataBind(); // Retrieve story information if story was submitted with the bookmarklet Url.Text = Request.QueryString["url"]; Title.Text = Request.QueryString["title"]; if (Title.Text.Length > 70) { Title.Text = Title.Text.Substring(0, 70); } if (Title.Text.Length > 0) { TitleNoteLabel.Text = "NOTE: Is this title correct?<br/>"; TitleNoteLabel.Visible = true; } Description.Text = Request.QueryString["description"]; if (Url.Text.Length == 0) { Url.Focus(); } else if (Title.Text.Length == 0) { Title.Focus(); } else { Description.Focus(); } } }
protected void Page_Load(object sender, EventArgs e) { Dal.Story story = StoryCache.GetStory(UrlParameters.StoryIdentifier, HostProfile.HostID); if (story == null || story.IsSpam && !this.KickUserProfile.IsModerator) { Response.Redirect("/missingstory"); } Title = story.Title; Caption = ""; UsersWhoKicked.DataBind(story.UsersWhoKicked); StorySummary.DataBind(story); StorySummary.ShowMoreLink = false; StorySummary.ShowGetKickImageCodeLink = true; CommentList.DataBind(StoryCache.GetComments(story.StoryID)); AddComment.DataBind(story.StoryID); DisplayAds = true; KickMenu.DisplayAds = true; KickMenu.DisplayCategories = false; KickMenu.DisplayWhatElse = false; KickItImagePersonalization.StoryUrl = story.Url; if (!String.IsNullOrEmpty(story.AdsenseID)) { if (KickUserProfile.UserID != story.UserID) { //flick a coin if (ThreadSafeRandom.FlickCoin()) { System.Diagnostics.Debug.WriteLine("Showing author ads " + story.AdsenseID); AdSenseID = story.AdsenseID; } } } //related stories control RelatedStories.DataBind(SimilarStoriesCache.GetSimilarStoryCollection(this.HostProfile.HostID, story.StoryID)); }