Finally, no spam! My blog was slowly becoming dysfunctional, after getting more than 2000 spam comments per day!
I moved to the new version 2.0 of http://dotnetblogengine.net last night, and it has super easy built in reCAPTCHA which stops spam and helps read books. Pretty cool! The reCAPTCHA settings are accessed by hovering over Tools and selecting Edit in .NET Blog Engine 2.0 – it was very hard and non-intuitive to find the setting, but once I did it worked like a charm!
There was one "small glitch" though – about a hundred thousand spam comments left to "moderate", which I did.
| Now I feel at peace like the picture on the left |
I made a small program, which anyone can use to mass-delete blog engine’s comments after specific date. Hopefully this will help anyone unspam themselves.
private void button1_Click(object sender, RoutedEventArgs e)
{
string[] files = Directory.GetFiles(@"D:\TEMP\blog\App_Data\posts", "*.xml");
foreach (string file in files)
{
FixPost(file);
}
}
private void FixPost(string fileName)
{
XDocument doc;
using (FileStream stream = File.OpenRead(fileName))
{
doc = XDocument.Load(stream);
}
var list = from XElement el in doc.Descendants(XName.Get("comment", String.Empty))
select el;
// convert the list to an array so that we're not modifying the collection that we're iterating over
XName date = XName.Get("date");
foreach (XElement el in list.ToArray())
{
string data = ((XElement)el.FirstNode).Value;
if (data.StartsWith("2011") || data.StartsWith("2010-12") || data.StartsWith("2010-11") || data.StartsWith("2010-10"))
{
el.Remove();
}
}
using (XmlWriter writer = XmlWriter.Create(fileName))
{
doc.WriteTo(writer);
}
}
That code deleted all comments from Oct 2010 onward (sorry, I had to do it), but yay! No spam! I can finally blog normally.
Hope you like it! Please comment in a nice and clean environment!