Ok, so having my blog has been nice, especially when I started receiving comments. Little did I realize the comments were auto comments that was just spam so people can post their website info for advertising. Well, after a while it got annoying trying to clean the comments. What I realized is, in the comments section, people can post a website url, which is the reason for the advertising. My first thought was I created a stored proc as follows:
create procedure dbo.spRemoveSpam as
delete from be_postcomment where isnull(Website,'')<>''
and isnull(Website,'') not like '%mypersonalwebsitehere%'
I then ran that every night. I could have created a trigger, but I just don't like them since I forget they exist and weird stuff happens! I also could have just scheduled this to run all the time. What I decided to do instead, was just add code into the file in the core dll file dbLogProvider.cs in the UpdateComments method, before the execute query, I changed the last line in that method:
cmd.ExecuteNonQuery();
TO
if (dpWebsite.Value == string.Empty) cmd.ExecuteNonQuery();
This will ensure that if someone fills in the website field, it just won't save. I will eventually put text on the page as well stating that, but thus far the only people that post in the website field are spammers.
I suppose a CAPTCHA would be nice, and I am sure there is a module somewhere, I am just being lazy!
12/1/2009 UPDATE
I found a better way to handle this. In the User Controls folder is a file called CommentsView.ascx.cs. Do a search for:
if (website.Trim().Length > 0)
{
if (!website.ToLowerInvariant().Contains("://"))
Right above the second IF statement, put a return. This will stop the post altogether from moving forward and emailing you. Final code looks like:
if (website.Trim().Length > 0)
{
return;
if (!website.ToLowerInvariant().Contains("://"))