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/>";
            }
        }
Exemple #2
0
        public string CheckStory(string url)
        {
            // check for dupes
            Story story = Story.FetchStoryByUrl(url);

            if (story != null)
            {
                return(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)));
            }
            //check for bannination
            if (BannedUrlHelper.IsUrlBanninated(url, HostCache.GetHost(HostHelper.GetHostAndPort(Request.Url)).HostID))
            {
                return("This url cannot be submitted.<br/>");
            }
            //returning null = everything's otay
            return(null);
        }