More spam wrangling

This commit is contained in:
Sebastiaan Janssen
2015-07-25 09:47:35 +02:00
parent 2fd131addc
commit 51c402e105
7 changed files with 91 additions and 21 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
+1
View File
@@ -1853,6 +1853,7 @@
<Content Include="Views\MacroPartials\Rss\Topic.cshtml" />
<Content Include="Views\MacroPartials\Rss\Participated.cshtml" />
<Content Include="Views\MacroPartials\Members\Activate.cshtml" />
<Content Include="Views\MacroPartials\Spam\Overview.cshtml" />
<None Include="Views\Partials\Forum\MemberBadge.cshtml" />
<Content Include="Views\Search\Search.aspx" />
<Content Include="Views\Web.config" />
@@ -215,12 +215,12 @@
<br /><br />
if (currentMember.IsHq())
{
var dbMember = UmbracoContext.Application.Services.MemberService.GetById(member.Id);
<div style="border: 1px solid red; padding: 4px;">
<p>HQ Tools (also known as "with great power comes great responsibility"):</p><br />
@{ var dbMember = UmbracoContext.Application.Services.MemberService.GetById(member.Id); }
<span>Member is approved? <strong>@dbMember.IsApproved</strong></span><br />
<a href="#" class="delete-member" style="color: red" rel="@member.Id">Delete this member</a><br />
<a href="#" class="delete-member-plus" style="color: red" rel="@member.Id">Delete this member including all their topics and comments</a><br />
@if (reputationCurrent < 71)
{
@@ -0,0 +1,22 @@
@using uForum.Extensions
@using uForum.Services
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@{
var memberService = UmbracoContext.Application.Services.MemberService;
var memberCount = 50;
var newMembers = memberService.GetMembersByMemberType("member").OrderByDescending(m => m.CreateDate).Take(memberCount);
var topicService = new TopicService(UmbracoContext.Application.DatabaseContext);
}
@if(Members.IsAdmin())
{
<h2>@memberCount newest members</h2>
<ul>
@foreach (var member in newMembers)
{
var topicsForMember = topicService.GetLatestTopicsForMember(member.Id, false);
var potentialSpammer = topicsForMember.Any(x => x.IsSpam);
<li><a href="/member/@member.Id" style="@(potentialSpammer ? "color: orange" : null)">@(potentialSpammer ? "[PotentialSpammer] " : null)<strong>Name: </strong>@member.Name - <strong>Approved: </strong> @member.IsApproved - <strong>Company: </strong>@(member.GetValue<string>("company")) - <strong>Posts: </strong>@topicsForMember.Count() - <strong>Bio: </strong>@(member.GetValue<string>("profileText"))</a></li>
}
</ul>
}
+1 -1
View File
@@ -81,7 +81,7 @@
<add key="uReleaseUsername" value="robotto" />
<add key="uReleasePassword" value="1234" />
<add key="uReleaseParentNodeId" value="50346" />
<add key="uForumSpamWords" value="Kitchen,kitchendesign1.co.uk,cheapkitchens9.co.uk,kitchenunitssale.co.uk,Cheap Kitchens,kitchendesign1,Budget Kitchen,Cheapest kitchen,Kitchens In Devon,Cheap DIY Kitchen Units,Kitchen Worktops,K-itchen,K*itchen,Investigação,ℬℒak,ℒℴvℰ※ℬak,divorce problem,91-9914703222,91-8284988896,love vashikaran,babi ji,babaji,marriage specialist,love problem solution,black magic specialist,love ke expert,vashikaran specialist,best pandit,BEst TAntRIK,办理英国" />
<add key="uForumSpamWords" value="Kitchen,kitchendesign1.co.uk,cheapkitchens9.co.uk,kitchenunitssale.co.uk,Cheap Kitchens,kitchendesign1,Budget Kitchen,Cheapest kitchen,Kitchens In Devon,Cheap DIY Kitchen Units,Kitchen Worktops,K-itchen,K*itchen,Investigação,ℬℒak,ℒℴvℰ※ℬak,divorce problem,91-9914703222,91-8284988896,love vashikaran,babi ji,baba ji,babaji,babiji,marriage specialist,love problem solution,black magic specialist,love ke expert,vashikaran specialist,best pandit,BEst TAntRIK,办理英国,best animator in" />
<add key="uForumSpamNotify" value="sebastiaan+ourspam@umbraco.com" />
<add key="uForumErrorNotify" value="sebastiaan+ourerror@umbraco.com" />
<add key="YahooPipesId" value="ed801a6b7fc181548f40eca16fdb03a7" />
+47
View File
@@ -20,6 +20,7 @@ namespace our
{
EnsureMigrationsMarkerPathExists();
MemberActivationMigration();
SpamOverview();
}
private void EnsureMigrationsMarkerPathExists()
@@ -84,5 +85,51 @@ namespace our
LogHelper.Error<MigrationsHandler>(string.Format("Migration: '{0}' failed", migrationName), ex);
}
}
private void SpamOverview()
{
var migrationName = MethodBase.GetCurrentMethod().Name;
try
{
var path = HostingEnvironment.MapPath(MigrationMarkersPath + migrationName + ".txt");
if (File.Exists(path))
return;
var macroService = UmbracoContext.Current.Application.Services.MacroService;
var macroAlias = "AntiSpam";
if (macroService.GetByAlias(macroAlias) == null)
{
// Run migration
var macro = new Macro
{
Name = "[Spam] Overview",
Alias = macroAlias,
ScriptingFile = "~/Views/MacroPartials/Spam/Overview.cshtml",
UseInEditor = true
};
macro.Save();
}
var contentService = UmbracoContext.Current.Application.Services.ContentService;
var rootNode = contentService.GetRootContent().OrderBy(x => x.SortOrder).First(x => x.ContentType.Alias == "Community");
var antiSpamPageName = "AntiSpam";
if(rootNode.Children().Any(x => x.Name == antiSpamPageName) == false)
{
var content = contentService.CreateContent(antiSpamPageName, rootNode.Id, "Textpage");
content.SetValue("bodyText", string.Format("<?UMBRACO_MACRO macroAlias=\"{0}\" />", macroAlias));
contentService.SaveAndPublishWithStatus(content);
}
string[] lines = { "" };
File.WriteAllLines(path, lines);
}
catch (Exception ex)
{
LogHelper.Error<MigrationsHandler>(string.Format("Migration: '{0}' failed", migrationName), ex);
}
}
}
}
+1 -1
View File
@@ -161,7 +161,7 @@ namespace uForum.Extensions
foreach (var role in roles)
{
if(role == "standard" || role.StartsWith("201") || role.ToLowerInvariant().Contains("vendor".ToLowerInvariant()) || role.ToLowerInvariant().Contains("wiki".ToLowerInvariant()))
if(role == "standard" || role.StartsWith("201") || role.ToLowerInvariant().Contains("vendor".ToLowerInvariant()) || role.ToLowerInvariant().Contains("wiki".ToLowerInvariant()) || role.ToLowerInvariant().Contains("potentialspam".ToLowerInvariant()))
continue;
if (role == "CoreContrib")