removed old plugins

added v0.1 of profanity determent plugin
This commit is contained in:
RaidMax 2018-03-28 23:40:57 -05:00
parent 9db8ad80ef
commit 25cefb8b6a
35 changed files with 211 additions and 4245 deletions

View File

@ -15,12 +15,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WelcomePlugin", "Plugins\We
{D51EECEB-438A-47DA-870F-7D7B41BC24D6} = {D51EECEB-438A-47DA-870F-7D7B41BC24D6}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VotemapPlugin", "Plugins\VoteMap\VotemapPlugin.csproj", "{428D8EB9-ECA3-4A66-AA59-3A944378C33F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Plugins", "Plugins", "{26E8B310-269E-46D4-A612-24601F16065F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FastRestartPlugin", "Plugins\FastRestart\FastRestartPlugin.csproj", "{1479DE87-ACB5-4046-81C8-A0BA5041227D}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8C8F3945-0AEF-4949-A1F7-B18E952E50BC}"
ProjectSection(SolutionItems) = preProject
_customcallbacks.gsc = _customcallbacks.gsc
@ -33,6 +29,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Plugins\Tests\Test
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebfrontCore", "WebfrontCore\WebfrontCore.csproj", "{65340D7D-5831-406C-ACAD-B13BA634BDE2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProfanityDeterment", "Plugins\ProfanityDeterment\ProfanityDeterment.csproj", "{3EA31029-C76F-4C8E-AFD4-79F77DEA7033}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -149,66 +147,6 @@ Global
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Stable|x64.Build.0 = Release-Stable|x64
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Stable|x86.ActiveCfg = Release-Stable|x86
{AF097E6B-48D5-4452-9CCF-0A81A21F341D}.Release-Stable|x86.Build.0 = Release-Stable|x86
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Debug|Mixed Platforms.Build.0 = Debug|x86
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Debug|x64.ActiveCfg = Debug|Any CPU
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Debug|x64.Build.0 = Debug|Any CPU
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Debug|x86.ActiveCfg = Debug|x86
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Debug|x86.Build.0 = Debug|x86
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release|Any CPU.ActiveCfg = Release-Stable|Any CPU
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release|Any CPU.Build.0 = Release-Stable|Any CPU
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release|Mixed Platforms.ActiveCfg = Release-Stable|x86
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release|Mixed Platforms.Build.0 = Release-Stable|x86
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release|x64.ActiveCfg = Release-Stable|Any CPU
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release|x64.Build.0 = Release-Stable|Any CPU
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release|x86.ActiveCfg = Release-Stable|x86
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release|x86.Build.0 = Release-Stable|x86
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release-Nightly|Any CPU.ActiveCfg = Release-Nightly|Any CPU
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release-Nightly|Mixed Platforms.ActiveCfg = Release-Nightly|x86
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release-Nightly|Mixed Platforms.Build.0 = Release-Nightly|x86
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release-Nightly|x64.ActiveCfg = Release-Nightly|Any CPU
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release-Nightly|x64.Build.0 = Release-Nightly|Any CPU
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release-Nightly|x86.ActiveCfg = Release-Nightly|Any CPU
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release-Nightly|x86.Build.0 = Release-Nightly|Any CPU
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release-Stable|Any CPU.ActiveCfg = Release-Stable|Any CPU
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release-Stable|Mixed Platforms.ActiveCfg = Release-Stable|x86
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release-Stable|Mixed Platforms.Build.0 = Release-Stable|x86
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release-Stable|x64.ActiveCfg = Release-Stable|Any CPU
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release-Stable|x64.Build.0 = Release-Stable|Any CPU
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release-Stable|x86.ActiveCfg = Release-Stable|Any CPU
{428D8EB9-ECA3-4A66-AA59-3A944378C33F}.Release-Stable|x86.Build.0 = Release-Stable|Any CPU
{1479DE87-ACB5-4046-81C8-A0BA5041227D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1479DE87-ACB5-4046-81C8-A0BA5041227D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1479DE87-ACB5-4046-81C8-A0BA5041227D}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{1479DE87-ACB5-4046-81C8-A0BA5041227D}.Debug|Mixed Platforms.Build.0 = Debug|x86
{1479DE87-ACB5-4046-81C8-A0BA5041227D}.Debug|x64.ActiveCfg = Debug|Any CPU
{1479DE87-ACB5-4046-81C8-A0BA5041227D}.Debug|x64.Build.0 = Debug|Any CPU
{1479DE87-ACB5-4046-81C8-A0BA5041227D}.Debug|x86.ActiveCfg = Debug|x86
{1479DE87-ACB5-4046-81C8-A0BA5041227D}.Debug|x86.Build.0 = Debug|x86
{1479DE87-ACB5-4046-81C8-A0BA5041227D}.Release|Any CPU.ActiveCfg = Release-Stable|Any CPU
{1479DE87-ACB5-4046-81C8-A0BA5041227D}.Release|Any CPU.Build.0 = Release-Stable|Any CPU
{1479DE87-ACB5-4046-81C8-A0BA5041227D}.Release|Mixed Platforms.ActiveCfg = Release-Stable|x86
{1479DE87-ACB5-4046-81C8-A0BA5041227D}.Release|Mixed Platforms.Build.0 = Release-Stable|x86
{1479DE87-ACB5-4046-81C8-A0BA5041227D}.Release|x64.ActiveCfg = Release-Stable|Any CPU
{1479DE87-ACB5-4046-81C8-A0BA5041227D}.Release|x64.Build.0 = Release-Stable|Any CPU
{1479DE87-ACB5-4046-81C8-A0BA5041227D}.Release|x86.ActiveCfg = Release-Stable|x86
{1479DE87-ACB5-4046-81C8-A0BA5041227D}.Release|x86.Build.0 = Release-Stable|x86
{1479DE87-ACB5-4046-81C8-A0BA5041227D}.Release-Nightly|Any CPU.ActiveCfg = Release-Nightly|Any CPU
{1479DE87-ACB5-4046-81C8-A0BA5041227D}.Release-Nightly|Mixed Platforms.ActiveCfg = Release-Nightly|x86
{1479DE87-ACB5-4046-81C8-A0BA5041227D}.Release-Nightly|Mixed Platforms.Build.0 = Release-Nightly|x86
{1479DE87-ACB5-4046-81C8-A0BA5041227D}.Release-Nightly|x64.ActiveCfg = Release-Nightly|Any CPU
{1479DE87-ACB5-4046-81C8-A0BA5041227D}.Release-Nightly|x64.Build.0 = Release-Nightly|Any CPU
{1479DE87-ACB5-4046-81C8-A0BA5041227D}.Release-Nightly|x86.ActiveCfg = Release-Nightly|Any CPU
{1479DE87-ACB5-4046-81C8-A0BA5041227D}.Release-Nightly|x86.Build.0 = Release-Nightly|Any CPU
{1479DE87-ACB5-4046-81C8-A0BA5041227D}.Release-Stable|Any CPU.ActiveCfg = Release-Stable|Any CPU
{1479DE87-ACB5-4046-81C8-A0BA5041227D}.Release-Stable|Mixed Platforms.ActiveCfg = Release-Stable|x86
{1479DE87-ACB5-4046-81C8-A0BA5041227D}.Release-Stable|Mixed Platforms.Build.0 = Release-Stable|x86
{1479DE87-ACB5-4046-81C8-A0BA5041227D}.Release-Stable|x64.ActiveCfg = Release-Stable|Any CPU
{1479DE87-ACB5-4046-81C8-A0BA5041227D}.Release-Stable|x64.Build.0 = Release-Stable|Any CPU
{1479DE87-ACB5-4046-81C8-A0BA5041227D}.Release-Stable|x86.ActiveCfg = Release-Stable|Any CPU
{1479DE87-ACB5-4046-81C8-A0BA5041227D}.Release-Stable|x86.Build.0 = Release-Stable|Any CPU
{B8C2A759-8663-4F6F-9BA4-19595F5E12C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B8C2A759-8663-4F6F-9BA4-19595F5E12C1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B8C2A759-8663-4F6F-9BA4-19595F5E12C1}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
@ -271,6 +209,38 @@ Global
{65340D7D-5831-406C-ACAD-B13BA634BDE2}.Release-Stable|x64.Build.0 = Release|Any CPU
{65340D7D-5831-406C-ACAD-B13BA634BDE2}.Release-Stable|x86.ActiveCfg = Release|x86
{65340D7D-5831-406C-ACAD-B13BA634BDE2}.Release-Stable|x86.Build.0 = Release|x86
{3EA31029-C76F-4C8E-AFD4-79F77DEA7033}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3EA31029-C76F-4C8E-AFD4-79F77DEA7033}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3EA31029-C76F-4C8E-AFD4-79F77DEA7033}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{3EA31029-C76F-4C8E-AFD4-79F77DEA7033}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{3EA31029-C76F-4C8E-AFD4-79F77DEA7033}.Debug|x64.ActiveCfg = Debug|Any CPU
{3EA31029-C76F-4C8E-AFD4-79F77DEA7033}.Debug|x64.Build.0 = Debug|Any CPU
{3EA31029-C76F-4C8E-AFD4-79F77DEA7033}.Debug|x86.ActiveCfg = Debug|x86
{3EA31029-C76F-4C8E-AFD4-79F77DEA7033}.Debug|x86.Build.0 = Debug|x86
{3EA31029-C76F-4C8E-AFD4-79F77DEA7033}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3EA31029-C76F-4C8E-AFD4-79F77DEA7033}.Release|Any CPU.Build.0 = Release|Any CPU
{3EA31029-C76F-4C8E-AFD4-79F77DEA7033}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{3EA31029-C76F-4C8E-AFD4-79F77DEA7033}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{3EA31029-C76F-4C8E-AFD4-79F77DEA7033}.Release|x64.ActiveCfg = Release|Any CPU
{3EA31029-C76F-4C8E-AFD4-79F77DEA7033}.Release|x64.Build.0 = Release|Any CPU
{3EA31029-C76F-4C8E-AFD4-79F77DEA7033}.Release|x86.ActiveCfg = Release|x86
{3EA31029-C76F-4C8E-AFD4-79F77DEA7033}.Release|x86.Build.0 = Release|x86
{3EA31029-C76F-4C8E-AFD4-79F77DEA7033}.Release-Nightly|Any CPU.ActiveCfg = Release|Any CPU
{3EA31029-C76F-4C8E-AFD4-79F77DEA7033}.Release-Nightly|Any CPU.Build.0 = Release|Any CPU
{3EA31029-C76F-4C8E-AFD4-79F77DEA7033}.Release-Nightly|Mixed Platforms.ActiveCfg = Release|Any CPU
{3EA31029-C76F-4C8E-AFD4-79F77DEA7033}.Release-Nightly|Mixed Platforms.Build.0 = Release|Any CPU
{3EA31029-C76F-4C8E-AFD4-79F77DEA7033}.Release-Nightly|x64.ActiveCfg = Release|Any CPU
{3EA31029-C76F-4C8E-AFD4-79F77DEA7033}.Release-Nightly|x64.Build.0 = Release|Any CPU
{3EA31029-C76F-4C8E-AFD4-79F77DEA7033}.Release-Nightly|x86.ActiveCfg = Release|x86
{3EA31029-C76F-4C8E-AFD4-79F77DEA7033}.Release-Nightly|x86.Build.0 = Release|x86
{3EA31029-C76F-4C8E-AFD4-79F77DEA7033}.Release-Stable|Any CPU.ActiveCfg = Release|Any CPU
{3EA31029-C76F-4C8E-AFD4-79F77DEA7033}.Release-Stable|Any CPU.Build.0 = Release|Any CPU
{3EA31029-C76F-4C8E-AFD4-79F77DEA7033}.Release-Stable|Mixed Platforms.ActiveCfg = Release|Any CPU
{3EA31029-C76F-4C8E-AFD4-79F77DEA7033}.Release-Stable|Mixed Platforms.Build.0 = Release|Any CPU
{3EA31029-C76F-4C8E-AFD4-79F77DEA7033}.Release-Stable|x64.ActiveCfg = Release|Any CPU
{3EA31029-C76F-4C8E-AFD4-79F77DEA7033}.Release-Stable|x64.Build.0 = Release|Any CPU
{3EA31029-C76F-4C8E-AFD4-79F77DEA7033}.Release-Stable|x86.ActiveCfg = Release|x86
{3EA31029-C76F-4C8E-AFD4-79F77DEA7033}.Release-Stable|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -278,9 +248,8 @@ Global
GlobalSection(NestedProjects) = preSolution
{4785AB75-66F3-4391-985D-63A5A049A0FA} = {26E8B310-269E-46D4-A612-24601F16065F}
{AF097E6B-48D5-4452-9CCF-0A81A21F341D} = {26E8B310-269E-46D4-A612-24601F16065F}
{428D8EB9-ECA3-4A66-AA59-3A944378C33F} = {26E8B310-269E-46D4-A612-24601F16065F}
{1479DE87-ACB5-4046-81C8-A0BA5041227D} = {26E8B310-269E-46D4-A612-24601F16065F}
{B8C2A759-8663-4F6F-9BA4-19595F5E12C1} = {26E8B310-269E-46D4-A612-24601F16065F}
{3EA31029-C76F-4C8E-AFD4-79F77DEA7033} = {26E8B310-269E-46D4-A612-24601F16065F}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {84F8F8E0-1F73-41E0-BD8D-BB6676E2EE87}

View File

@ -1,88 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{C9E821BF-23AD-4CB5-B7F9-B3B99B606650}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>EventAPI</RootNamespace>
<AssemblyName>EventAPI</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release-Nightly|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release-Stable|AnyCPU'">
<OutputPath>bin\Release-Stable\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<PlatformTarget>x86</PlatformTarget>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release-Nightly|x86' ">
<PlatformTarget>x86</PlatformTarget>
<OutputPath>bin\x86\Release\</OutputPath>
<Optimize>true</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release-Stable|x86'">
<PlatformTarget>x86</PlatformTarget>
<OutputPath>bin\x86\Release-Stable\</OutputPath>
<Optimize>true</Optimize>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\SharedLibrary\SharedLibrary.csproj">
<Project>{d51eeceb-438a-47da-870f-7d7b41bc24d6}</Project>
<Name>SharedLibrary</Name>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="Plugin.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>copy /Y "$(TargetDir)$(TargetName).dll" "$(SolutionDir)BUILD\plugins\"</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -1,121 +0,0 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using SharedLibrary;
using SharedLibrary.Interfaces;
using SharedLibrary.Objects;
namespace EventAPI
{
class Events : IPlugin
{
public static Queue<RestEvent> APIEvents { get; private set; }
public static List<Server> ActiveServers;
DateTime lastClear;
int flaggedMessages;
List<string> flaggedMessagesText;
public String Name => "Event API Plugin";
public float Version => 1.0f;
public string Author => "RaidMax";
public async Task OnLoadAsync(IManager manager)
{
APIEvents = new Queue<RestEvent>();
flaggedMessagesText = new List<string>();
ActiveServers = new List<Server>();
}
public async Task OnUnloadAsync()
{
APIEvents.Clear();
ActiveServers.Clear();
}
public async Task OnTickAsync(Server S)
{
return;
}
public async Task OnEventAsync(Event E, Server S)
{
if (E.Type == Event.GType.Start)
{
ActiveServers.Add(S);
}
if (E.Type == Event.GType.Stop)
{
ActiveServers.RemoveAll(s => s.GetHashCode() == S.GetHashCode());
}
if (E.Type == Event.GType.Connect)
{
AddRestEvent(new RestEvent(RestEvent.EventType.NOTIFICATION, RestEvent.EventVersion.IW4MAdmin, E.Origin.Name + " has joined " + S.Hostname, E.Type.ToString(), S.Hostname, E.Origin.Name));
}
if (E.Type == Event.GType.Disconnect)
{
AddRestEvent(new RestEvent(RestEvent.EventType.NOTIFICATION, RestEvent.EventVersion.IW4MAdmin, E.Origin.Name + " has left " + S.Hostname, E.Type.ToString(), S.Hostname, E.Origin.Name));
}
if (E.Type == Event.GType.Say)
{
if (E.Data.Length != 0 && E.Data[0] != '!')
AddRestEvent(new RestEvent(RestEvent.EventType.NOTIFICATION, RestEvent.EventVersion.IW4MAdmin, E.Data, "Chat", E.Origin.Name, ""));
}
if (E.Type == Event.GType.Report)
{
AddRestEvent(new RestEvent(RestEvent.EventType.ALERT, RestEvent.EventVersion.IW4MAdmin, $"**{E.Origin.Name}** has reported **{E.Target.Name}** for: {E.Data.Trim()}", E.Target.Name, E.Origin.Name, ""));
}
if (E.Type == Event.GType.Say && E.Origin.Level < Player.Permission.Moderator)
{
string message = E.Data.ToLower();
bool flagged = message.Contains(" wh ") ||
message.Contains("hax") ||
message.Contains("cheat") ||
message.Contains(" hack ") ||
message.Contains("aim") ||
message.Contains("wall") ||
message.Contains("cheto") ||
message.Contains("hak") ||
message.Contains(" bot ");
if (flagged)
{
flaggedMessages++;
flaggedMessagesText.Add(String.Format("{0}: {1}", E.Origin.Name, E.Data));
}
if (flaggedMessages > 3)
{
await E.Owner.Broadcast("If you suspect someone of ^5CHEATING ^7use the ^5!report ^7command");
AddRestEvent(new RestEvent(RestEvent.EventType.ALERT, RestEvent.EventVersion.IW4MAdmin, "Chat indicates there may be a cheater", "Alert", E.Owner.Hostname, ""));
AddRestEvent(new RestEvent(RestEvent.EventType.NOTIFICATION, RestEvent.EventVersion.IW4MAdmin, String.Join("\n", flaggedMessagesText), "Chat Monitor", E.Owner.Hostname, ""));
flaggedMessages = 0;
}
else if ((DateTime.Now - lastClear).TotalMinutes >= 3)
{
flaggedMessages = 0;
flaggedMessagesText.Clear();
lastClear = DateTime.Now;
}
}
}
public static void AddRestEvent(RestEvent E)
{
if (APIEvents.Count > 20)
APIEvents.Dequeue();
APIEvents.Enqueue(E);
}
}
}

View File

@ -1,129 +0,0 @@
using System;
using System.Threading.Tasks;
using System.Collections.Generic;
using SharedLibrary;
using SharedLibrary.Interfaces;
using SharedLibrary.Network;
using SharedLibrary.Helpers;
using SharedLibrary.Objects;
namespace Plugin
{
public class FastRestartConfig : Serialize<FastRestartConfig>
{
public bool Enabled;
}
public class CEnableFastRestart : Command
{
public CEnableFastRestart() : base("frenable", "enable fast restarting at the end of a map", "fre", Player.Permission.SeniorAdmin, false) { }
public override async Task ExecuteAsync(Event E)
{
FastRestartPlugin.ConfigManager.UpdateProperty(E.Owner, new KeyValuePair<string, object>("Enabled", true));
await E.Origin.Tell("Fast restarting is now enabled for this server");
}
}
public class CDisableFastRestart : Command
{
public CDisableFastRestart() : base("fredisable", "disable fast restarting at the end of a map", "frd", Player.Permission.SeniorAdmin, false) { }
public override async Task ExecuteAsync(Event E)
{
FastRestartPlugin.ConfigManager.UpdateProperty(E.Owner, new KeyValuePair<string, object>("Enabled", false));
await E.Origin.Tell("Fast restarting is now disabled for this server");
}
}
public class FastRestartPlugin : IPlugin
{
bool MatchEnded;
DateTime MatchEndTime;
Dictionary<int, int> FastRestarts;
public static ConfigurationManager ConfigManager { get; private set; }
public string Name => "Fast Restarter";
public float Version => 1.0f;
public string Author => "RaidMax";
public async Task OnEventAsync(Event E, Server S)
{
if (E.Type == Event.GType.Start)
{
ConfigManager.AddConfiguration(S);
if (ConfigManager.GetConfiguration(S).Keys.Count == 0)
ConfigManager.AddProperty(S, new KeyValuePair<string, object>("Enabled", false));
FastRestarts.Add(S.GetHashCode(), 0);
try
{
await S.GetDvarAsync<int>("scr_intermission_time");
}
catch (SharedLibrary.Exceptions.DvarException)
{
await S.SetDvarAsync("scr_intermission_time", 20);
}
}
}
public async Task OnLoadAsync(IManager manager)
{
ConfigManager = new ConfigurationManager(typeof(FastRestartPlugin));
FastRestarts = new Dictionary<int, int>();
}
public async Task OnTickAsync(Server S)
{
if ((bool)ConfigManager.GetConfiguration(S)["Enabled"] == false)
return;
MatchEnded = (await S.GetDvarAsync<int>("scr_gameended")).Value == 1;
if (MatchEnded && MatchEndTime == DateTime.MinValue)
MatchEndTime = DateTime.Now;
int intermissionTime = 20;
try
{
var intermissionTimeDvar = await S.GetDvarAsync<int>("scr_intermission_time");
intermissionTime = intermissionTimeDvar.Value;
}
catch(SharedLibrary.Exceptions.DvarException)
{
await S.SetDvarAsync("scr_intermission_time", 20);
}
// I'm pretty sure the timelength from game ended to scoreboard popup is 2000ms
if (MatchEnded && (DateTime.Now - MatchEndTime).TotalSeconds >= intermissionTime - 2)
{
if (FastRestarts[S.GetHashCode()] >= 8)
{
await S.ExecuteCommandAsync("map_restart");
FastRestarts[S.GetHashCode()] = 0;
}
else
{
await S.ExecuteCommandAsync("fast_restart");
FastRestarts[S.GetHashCode()] = FastRestarts[S.GetHashCode()] + 1;
}
MatchEndTime = DateTime.MinValue;
}
}
public async Task OnUnloadAsync()
{
}
}
}

View File

@ -1,43 +0,0 @@
using System;
using System.Security.Cryptography;
using System.Text;
//http://codereview.stackexchange.com/questions/96494/user-password-encryption-in-c + SCrypt
namespace MessageBoard.Encryption
{
public static class PasswordHasher
{
public static byte[] ComputeHash(string password, byte[] salt)
{
byte[] pwBytes = Encoding.UTF8.GetBytes(password);
byte[] hashBytes = new byte[64];
CryptSharp.Utility.SCrypt.ComputeKey(pwBytes, salt, 16384, 8, 1, null, hashBytes);
return hashBytes;
}
public static byte[] GenerateSalt(int saltByteSize = 24)
{
RNGCryptoServiceProvider saltGenerator = new RNGCryptoServiceProvider();
byte[] salt = new byte[saltByteSize];
saltGenerator.GetBytes(salt);
return salt;
}
public static bool VerifyPassword(String password, byte[] passwordSalt, byte[] passwordHash)
{
byte[] computedHash = ComputeHash(password, passwordSalt);
return AreHashesEqual(computedHash, passwordHash);
}
//Length constant verification - prevents timing attack
private static bool AreHashesEqual(byte[] firstHash, byte[] secondHash)
{
int minHashLength = firstHash.Length <= secondHash.Length ? firstHash.Length : secondHash.Length;
var xor = firstHash.Length ^ secondHash.Length;
for (int i = 0; i < minHashLength; i++)
xor |= firstHash[i] ^ secondHash[i];
return 0 == xor;
}
}
}

View File

@ -1,9 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MessageBoard.Events
{
public delegate void ActionEventHandler(User origin, EventArgs e);
}

View File

@ -1,33 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MessageBoard.Exceptions
{
public class ThreadException : Exception
{
public ThreadException(string msg) : base(msg) { }
}
public class UserException : Exception
{
public UserException(string msg) : base(msg) { }
}
public class SessionException : Exception
{
public SessionException(string msg) : base(msg) { }
}
public class CategoryException : Exception
{
public CategoryException(string msg) : base(msg) { }
}
public class PermissionException: Exception
{
public PermissionException(string msg) : base(msg) { }
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MessageBoard
{
interface Identifiable
{
int getID();
}
}

View File

@ -1,158 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{E46C85BD-A99C-484E-BCCE-0F1831C5925E}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MessageBoard</RootNamespace>
<AssemblyName>MessageboardPlugin</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release-Nightly|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release-Stable|AnyCPU'">
<OutputPath>bin\Release-Stable\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<PlatformTarget>x86</PlatformTarget>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release-Nightly|x86' ">
<PlatformTarget>x86</PlatformTarget>
<OutputPath>bin\x86\Release\</OutputPath>
<Optimize>true</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release-Stable|x86'">
<PlatformTarget>x86</PlatformTarget>
<OutputPath>bin\x86\Release-Stable\</OutputPath>
<Optimize>true</Optimize>
</PropertyGroup>
<ItemGroup>
<Compile Include="Encryption.cs" />
<Compile Include="Events.cs" />
<Compile Include="Exceptions.cs" />
<Compile Include="Forum.cs" />
<Compile Include="Identifiable.cs" />
<Compile Include="Plugin.cs" />
<Compile Include="Rank.cs" />
<Compile Include="Session.cs" />
<Compile Include="Storage.cs" />
<Compile Include="Thread.cs" />
<Compile Include="User.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="CodeKicker.BBCode, Version=5.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\CodeKicker.BBCode.5.0.0.0\lib\net35\CodeKicker.BBCode.dll</HintPath>
</Reference>
<Reference Include="CryptSharp, Version=1.2.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\CryptSharp.1.2.0.1\lib\net35\CryptSharp.dll</HintPath>
</Reference>
<Reference Include="DNA.Text, Version=2.1.1.10633, Culture=neutral, PublicKeyToken=f393b6ce92960100, processorArchitecture=MSIL">
<HintPath>..\..\packages\DNA.Text.2.1.1.10633\lib\DNA.Text.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\packages\Newtonsoft.Json.10.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Data.SQLite">
<HintPath>..\..\Admin\lib\System.Data.SQLite.dll</HintPath>
</Reference>
<Reference Include="System.Security" />
<Reference Include="System.Web" />
<Reference Include="System.XML" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Content Include="forum\category.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="forum\home.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="forum\login.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="forum\postthread.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="forum\register.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="forum\thread.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="forum\user.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="forum\usercp.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Service References\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\SharedLibrary\SharedLibrary.csproj">
<Project>{d51eeceb-438a-47da-870f-7d7b41bc24d6}</Project>
<Name>SharedLibrary</Name>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>mkdir "$(SolutionDir)Admin\bin\$(ConfigurationName)\forum"
xcopy /E /Y "$(TargetDir)forum" "$(SolutionDir)Admin\bin\$(ConfigurationName)\forum"
copy /Y "$(TargetDir)DNA.Text.dll" "$(SolutionDir)Admin\bin\$(ConfigurationName)\lib\DNA.Text.dll"
copy /Y "$(TargetDir)CryptSharp.dll" "$(SolutionDir)Admin\bin\$(ConfigurationName)\lib\CryptSharp.dll"
copy /Y "$(TargetDir)CodeKicker.BBcode.dll" "$(SolutionDir)Admin\bin\$(ConfigurationName)\lib\CodeKicker.BBcode.dll"
if $(ConfigurationName) == Debug copy /Y "$(TargetDir)$(TargetName).dll" "$(SolutionDir)BUILD\plugins\"</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -1,56 +0,0 @@
using System;
using SharedLibrary;
using SharedLibrary.Interfaces;
using System.Threading.Tasks;
namespace MessageBoard.Plugin
{
public class Main : IPlugin
{
public static Forum.Manager ManagerInstance { get; private set; }
public string Author
{
get
{
return "RaidMax";
}
}
public float Version
{
get
{
return 0.1f;
}
}
public string Name
{
get
{
return "Message Board Plugin";
}
}
public async Task OnLoadAsync(IManager manager)
{
ManagerInstance = new Forum.Manager();
ManagerInstance.Start();
}
public async Task OnUnloadAsync()
{
ManagerInstance.Stop();
}
public async Task OnTickAsync(Server S)
{
return;
}
public async Task OnEventAsync(Event E, Server S)
{
}
}
}

View File

@ -1,63 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SharedLibrary.Objects;
namespace MessageBoard
{
public class Rank : Identifiable
{
public string name;
public Player.Permission equivalentRank;
public int id;
/// <summary>
/// Initial creation
/// </summary>
/// <param name="name"></param>
/// <param name="equivalentRank"></param>
/// <param name="permissions"></param>
public Rank(string name, Player.Permission equivalentRank)
{
this.name = name;
this.equivalentRank = equivalentRank;
id = 0;
}
public Rank(int id, string name, Player.Permission equivalentRank)
{
this.name = name;
this.equivalentRank = equivalentRank;
this.id = id;
}
public int getID()
{
return id;
}
}
public class Permission
{
[Flags]
public enum Action
{
NONE = 0x0,
READ = 0x1,
WRITE = 0x2,
MODIFY = 0x4,
DELETE = 0x8
}
public int rankID;
public Action actionable;
public Permission(int rankID, Action actionable)
{
this.rankID = rankID;
this.actionable = actionable;
}
}
}

View File

@ -1,22 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MessageBoard
{
public class Session
{
public User sessionUser;
public string sessionID { get; private set; }
public DateTime sessionStartTime;
public Session(User sessionUser, string sessionID)
{
this.sessionUser = sessionUser;
this.sessionID = sessionID;
sessionStartTime = DateTime.Now;
}
}
}

View File

@ -1,623 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
namespace MessageBoard.Storage
{
class Database : SharedLibrary._Database
{
public Database(String FN, SharedLibrary.Interfaces.ILogger logger) : base(FN, logger) { }
public override void Init()
{
if (!System.IO.File.Exists(FileName))
{
string createClientTable = @"CREATE TABLE IF NOT EXISTS [USERS] (
[id] INTEGER PRIMARY KEY AUTOINCREMENT,
[ranking] INTEGER DEFAULT 0,
[username] TEXT COLLATE NOCASE NOT NULL,
[email] TEXT NOT NULL,
[passwordhash] TEXT NOT NULL,
[passwordsalt] TEXT NOT NULL,
[lastlogin] TEXT NOT NULL,
[creationdate] TEXT NOT NULL,
[subscribedthreads] TEXT DEFAULT 0,
[avatarurl] TEXT
);";
string createSessionTable = @"CREATE TABLE IF NOT EXISTS [SESSIONS] (
[sessionid] TEXT NOT NULL,
[sessionuserid] INTEGER NOT NULL,
FOREIGN KEY(sessionuserid) REFERENCES USERS(id)
);";
string createRankingTable = @"CREATE TABLE IF NOT EXISTS [RANKS] (
[id] INTEGER PRIMARY KEY AUTOINCREMENT,
[name] TEXT UNIQUE NOT NULL,
[equivalentrank] INTEGER DEFAULT 0
);";
string createCategoryTable = @"CREATE TABLE IF NOT EXISTS [CATEGORIES] (
[id] INTEGER PRIMARY KEY AUTOINCREMENT,
[title] TEXT NOT NULL,
[description] TEXT NOT NULL,
[permissions] BLOB
);";
string createThreadTable = @"CREATE TABLE IF NOT EXISTS [THREADS] (
[id] INTEGER PRIMARY KEY AUTOINCREMENT,
[title] TEXT NOT NULL,
[categoryid] INTEGER NOT NULL,
[replies] INTEGER DEFAULT 0,
[authorid] INTEGER NOT NULL,
[creationdate] TEXT NOT NULL,
[updateddate] TEXT NOT NULL,
[content] TEXT NOT NULL,
[visible] INTEGER DEFAULT 1,
FOREIGN KEY(authorid) REFERENCES USERS(id),
FOREIGN KEY(categoryid) REFERENCES CATEGORIES(id)
);";
string createReplyTable = @"CREATE TABLE IF NOT EXISTS [REPLIES] (
[id] INTEGER PRIMARY KEY AUTOINCREMENT,
[title] TEXT NOT NULL,
[authorid] INT NOT NULL,
[threadid] INT NOT NULL,
[creationdate] TEXT NOT NULL,
[updateddate] TEXT NOT NULL,
[content] TEXT NOT NULL,
[visible] INTEGER DEFAULT 1,
FOREIGN KEY(authorid) REFERENCES USERS(id),
FOREIGN KEY(threadid) REFERENCES THREADS(id)
);";
string createUserProfileTable = @"CREATE TABLE IF NOT EXISTS [PROFILES] (
[id] INTEGER PRIMARY KEY AUTOINCREMENT,
[userid] INTEGER NOT NULL,
[showemail] INTEGER DEFAULT 1,
[bannercolor] TEXT DEFAULT '#ff6633',
[birthday] TEXT,
[showage] INTEGER DEFAULT 0
);";
ExecuteNonQuery(createClientTable);
ExecuteNonQuery(createSessionTable);
ExecuteNonQuery(createRankingTable);
ExecuteNonQuery(createCategoryTable);
ExecuteNonQuery(createThreadTable);
ExecuteNonQuery(createReplyTable);
ExecuteNonQuery(createUserProfileTable);
Rank guestRank = new Rank(1, "Guest", SharedLibrary.Player.Permission.User);
Rank userRank = new Rank(2, "User", SharedLibrary.Player.Permission.Trusted);
Rank modRank = new Rank(3, "Moderator", SharedLibrary.Player.Permission.Moderator);
Rank adminRank = new Rank(4, "Administrator", SharedLibrary.Player.Permission.Owner);
addRank(guestRank);
addRank(userRank);
addRank(modRank);
addRank(adminRank);
List<Permission> defaultCatPerms = new List<Permission> {
new Permission(guestRank.getID(), Permission.Action.READ),
new Permission(userRank.getID(), Permission.Action.READ | Permission.Action.WRITE),
new Permission(modRank.getID(), Permission.Action.READ | Permission.Action.WRITE | Permission.Action.MODIFY),
new Permission(adminRank.getID(), Permission.Action.READ | Permission.Action.WRITE | Permission.Action.MODIFY | Permission.Action.DELETE)
};
Category defaultCat = new Category(1, "Default Category", "This is the default category.", defaultCatPerms);
addCategory(defaultCat);
}
}
#region SESSIONS
public Session getSession(string sessionID)
{
DataTable Result = GetDataTable("SESSIONS", new KeyValuePair<string, object>("sessionid", sessionID));
if (Result != null && Result.Rows.Count > 0)
{
DataRow ResponseRow = Result.Rows[0];
int userID = Int32.Parse(ResponseRow["sessionuserid"].ToString());
User sessionUser = getUser(userID);
// this shouldn't happen.. but it might :c
if (sessionUser == null)
return null;
Session foundSession = new Session(sessionUser, sessionID);
return foundSession;
}
else
return null;
}
public Session setSession(int userID, string sessionID)
{
// prevent duplicated tuples
if (getSession(sessionID) != null)
{
updateSession(sessionID, userID);
return getSession(sessionID);
}
Dictionary<String, object> newSession = new Dictionary<String, object>();
newSession.Add("sessionid", sessionID);
newSession.Add("sessionuserid", userID);
Insert("SESSIONS", newSession);
return getSession(sessionID);
}
public void removeSession(string sessionID)
{
ExecuteNonQuery(String.Format("DELETE FROM SESSIONS WHERE sessionid = '{0}'", sessionID));
}
public bool updateSession(string sessionID, int userID)
{
if (getSession(sessionID) == null)
return false;
Dictionary<string, object> updatedSession = new Dictionary<string, object>();
updatedSession.Add("sessionuserid", userID);
Update("SESSIONS", updatedSession, new KeyValuePair<string, object>("sessionid", sessionID));
return true;
}
#endregion
#region USERS
private User getUserFromDataTable(DataTable Result)
{
if (Result != null && Result.Rows.Count > 0)
{
DataRow ResponseRow = Result.Rows[0];
int id = Convert.ToInt32(ResponseRow["id"].ToString());
string passwordHash = ResponseRow["passwordhash"].ToString();
string passwordSalt = ResponseRow["passwordsalt"].ToString();
string username = ResponseRow["username"].ToString();
string email = ResponseRow["email"].ToString();
DateTime lastLogon = DateTime.Parse(ResponseRow["lastlogin"].ToString());
DateTime creationDate = DateTime.Parse(ResponseRow["creationdate"].ToString());
Rank ranking = getRank(Convert.ToInt32(ResponseRow["ranking"]));
string avatarURL = ResponseRow["avatarurl"].ToString();
string posts = GetDataTable(String.Format("select (select count(*) from THREADS where authorid = {0}) + (select count(*) from REPLIES where authorid = {0}) as posts;", id)).Rows[0]["posts"].ToString();
User foundUser = new User(id, passwordHash, passwordSalt, username, email, Convert.ToInt32(posts), lastLogon, creationDate, ranking, avatarURL);
return foundUser;
}
return null;
}
private Dictionary<string, object> getDataTableFromUser(User addedUser)
{
Dictionary<String, object> newUser = new Dictionary<String, object>();
newUser.Add("username", addedUser.username);
newUser.Add("email", addedUser.email);
newUser.Add("passwordhash", addedUser.getPasswordHash());
newUser.Add("passwordsalt", addedUser.getPasswordSalt());
newUser.Add("lastlogin", SharedLibrary.Utilities.DateTimeSQLite(addedUser.lastLogin));
newUser.Add("creationdate", SharedLibrary.Utilities.DateTimeSQLite(addedUser.creationDate));
//newUser.Add("subscribedthreads", String.Join<int>(",", addedUser.subscribedThreads));
newUser.Add("ranking", addedUser.ranking.getID());
newUser.Add("avatarurl", addedUser.avatarURL);
return newUser;
}
public User getUser(int userid)
{
DataTable Result = GetDataTable("USERS", new KeyValuePair<string, object>("id", userid));
return getUserFromDataTable(Result);
}
public User getUser(string username)
{
DataTable Result = GetDataTable("USERS", new KeyValuePair<string, object>("username", username));
return getUserFromDataTable(Result);
}
public bool userExists(string username, string email)
{
String Query = String.Format("SELECT * FROM USERS WHERE username = '{0}' or email = '{1}'", username, email);
DataTable Result = GetDataTable(Query);
return Result.Rows.Count > 0;
}
/// <summary>
/// Returns ID of added user
/// </summary>
/// <param name="addedUser"></param>
/// <param name="userSession"></param>
/// <returns></returns>
public User addUser(User addedUser, Session userSession)
{
var newUser = getDataTableFromUser(addedUser);
Insert("USERS", newUser);
// fixme
User createdUser = getUser(addedUser.username);
return createdUser;
}
public bool updateUser(User updatedUser)
{
var user = getDataTableFromUser(updatedUser);
Update("USERS", user, new KeyValuePair<string, object>("id", updatedUser.getID()));
return true;
}
public int getNumUsers()
{
var Result = GetDataTable("SELECT COUNT(id) AS userCount FROM `USERS`;");
return Convert.ToInt32(Result.Rows[0]["userCount"]);
}
#endregion
#region CATEGORIES
private Category getCategoryFromDataTable(DataTable Result)
{
if (Result != null && Result.Rows.Count > 0)
{
DataRow ResponseRow = Result.Rows[0];
int id = Convert.ToInt32(ResponseRow["id"]);
string title = ResponseRow["title"].ToString();
string description = ResponseRow["description"].ToString();
string permissions = Encoding.UTF8.GetString((byte[])ResponseRow["permissions"]);
List<Permission> perms = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Permission>>(permissions);
Category requestedCategory = new Category(id, title, description, perms);
return requestedCategory;
}
return null;
}
public void addCategory(Category addingCategory)
{
Dictionary<String, object> newCategory = new Dictionary<string, object>();
newCategory.Add("title", addingCategory.title);
newCategory.Add("description", addingCategory.description);
newCategory.Add("permissions", Newtonsoft.Json.JsonConvert.SerializeObject(addingCategory.permissions));
Insert("CATEGORIES", newCategory);
}
public Category getCategory(int id)
{
string Query = String.Format("SELECT * FROM CATEGORIES WHERE id = {0}", id);
DataTable Result = GetDataTable(Query);
return getCategoryFromDataTable(Result);
}
public List<Category> getAllCategories()
{
string Query = String.Format("SELECT id FROM CATEGORIES");
List<Category> cats = new List<Category>();
DataTable Result = GetDataTable(Query);
if (Result != null && Result.Rows.Count > 0)
{
for (int i = 0; i < Result.Rows.Count; i++)
cats.Add(getCategory(Convert.ToInt32(Result.Rows[i]["id"])));
}
return cats;
}
#endregion
#region THREADS
public Dictionary<string, object> getDataTableFromThread(ForumThread Thread)
{
Dictionary<string, object> newThread = new Dictionary<string, object>();
newThread.Add("title", Thread.title);
newThread.Add("categoryid", Thread.threadCategory.getID());
newThread.Add("replies", Thread.replies);
newThread.Add("authorid", Thread.author.getID());
newThread.Add("creationdate", SharedLibrary.Utilities.DateTimeSQLite(Thread.creationDate));
newThread.Add("updateddate", SharedLibrary.Utilities.DateTimeSQLite(Thread.updatedDate));
newThread.Add("content", Thread.content);
newThread.Add("visible", Convert.ToInt32(Thread.visible));
return newThread;
}
public int addThread(ForumThread Thread)
{
Insert("THREADS", getDataTableFromThread(Thread));
return getThreadID(Thread.creationDate);
}
public bool updateThread(ForumThread updatedThread)
{
var user = getDataTableFromThread(updatedThread);
Update("THREADS", user, new KeyValuePair<string, object>("id", updatedThread.getID()));
return true;
}
public ForumThread getThread(int id)
{
DataTable Result = GetDataTable("THREADS", new KeyValuePair<string, object>("id", id));
return getThreadFromDataTable(Result);
}
private ForumThread getThreadFromDataTable(DataTable Result)
{
if (Result != null && Result.Rows.Count > 0)
{
DataRow ResponseRow = Result.Rows[0];
int id = Convert.ToInt32(ResponseRow["id"].ToString());
int categoryid = Convert.ToInt32(ResponseRow["categoryid"].ToString());
int authorid = Convert.ToInt32(ResponseRow["authorid"].ToString());
int replies = Convert.ToInt32(ResponseRow["replies"].ToString());
string title = ResponseRow["title"].ToString();
var category = getCategory(categoryid);
var author = getUser(authorid);
bool visible = Convert.ToBoolean((Convert.ToInt32(ResponseRow["visible"])));
DateTime creationDate = DateTime.Parse(ResponseRow["creationdate"].ToString());
DateTime updatedDate = DateTime.Parse(ResponseRow["updateddate"].ToString());
string content = ResponseRow["content"].ToString();
ForumThread retrievedThread = new ForumThread(id, title, visible, content, replies, author, category, creationDate, updatedDate);
return retrievedThread;
}
return null;
}
// we have no other unique id yet
private int getThreadID(DateTime creationDate)
{
string Query = String.Format("SELECT * FROM THREADS WHERE creationdate = \"{0}\"", SharedLibrary.Utilities.DateTimeSQLite(creationDate));
DataTable Result = GetDataTable(Query);
if (Result != null && Result.Rows.Count > 0)
return Convert.ToInt32(Result.Rows[0]["id"].ToString());
return 0;
}
public List<ForumThread> getRecentThreads(int categoryID)
{
List<ForumThread> threads = new List<ForumThread>();
string Query = String.Format("SELECT id FROM THREADS WHERE categoryid = {0} AND visible = 1 ORDER BY `updateddate` DESC LIMIT 3", categoryID);
DataTable Result = GetDataTable(Query);
if (Result != null && Result.Rows.Count > 0)
{
for (int i = 0; i < Result.Rows.Count; i++)
threads.Add(getThread(Convert.ToInt32(Result.Rows[i]["id"])));
}
return threads;
}
public List<ForumThread> getCategoryThreads(int categoryID)
{
List<ForumThread> threads = new List<ForumThread>();
string Query = String.Format("SELECT id FROM THREADS WHERE categoryid = {0} and visible = 1 ORDER BY `updateddate` DESC", categoryID);
DataTable Result = GetDataTable(Query);
if (Result != null && Result.Rows.Count > 0)
{
for (int i = 0; i < Result.Rows.Count; i++)
threads.Add(getThread(Convert.ToInt32(Result.Rows[i]["id"])));
}
return threads;
}
#endregion
#region RANKING
public int addRank(Rank newRank)
{
Dictionary<string, object> rank = new Dictionary<string, object>();
rank.Add("name", newRank.name);
rank.Add("equivalentrank", (int)newRank.equivalentRank);
Insert("RANKS", rank);
Rank r = getRank(newRank.name);
if (r == null)
return 0;
return r.getID();
}
public Rank getRank(string rankName)
{
DataTable Result = GetDataTable("RANKS", new KeyValuePair<string, object>("name", rankName));
if (Result != null && Result.Rows.Count > 0)
{
DataRow ResponseRow = Result.Rows[0];
string name = ResponseRow["name"].ToString();
int equivRank = Convert.ToInt32(ResponseRow["equivalentrank"].ToString());
int id = Convert.ToInt32(ResponseRow["id"].ToString());
Rank retrievedRank = new Rank(id, name, (SharedLibrary.Player.Permission)equivRank);
return retrievedRank;
}
return null;
}
public Rank getRank(int rankID)
{
DataTable Result = GetDataTable("RANKS", new KeyValuePair<string, object>("id", rankID));
if (Result != null && Result.Rows.Count > 0)
{
DataRow ResponseRow = Result.Rows[0];
string name = ResponseRow["name"].ToString();
int equivRank = Convert.ToInt32(ResponseRow["equivalentrank"].ToString());
Rank retrievedRank = new Rank(rankID, name, (SharedLibrary.Player.Permission)equivRank);
return retrievedRank;
}
return null;
}
#endregion
#region REPLIES
public int addReply(Post reply)
{
Insert("REPLIES", getDataTableFromReply(reply));
return getReplyID(reply.creationDate);
}
public bool updateReply(Post reply)
{
return Update("REPLIES", getDataTableFromReply(reply), new KeyValuePair<string, object>("id", reply.id));
}
public Post getReply(int id)
{
DataTable Result = GetDataTable("REPLIES", new KeyValuePair<string, object>("id", id));
return getReplyFromDataTable(Result);
}
public List<Post> getRepliesFromThreadID(int threadID)
{
List<Post> replies = new List<Post>();
//var Result = GetDataTable("REPLIES", new KeyValuePair<string, object>("threadid", threadID));
var Result = GetDataTable("SELECT * FROM REPLIES WHERE threadid = " + threadID + " AND visible = 1");
foreach (DataRow row in Result.Rows)
{
replies.Add(getReply(Convert.ToInt32(row["id"].ToString())));
}
return replies;
}
private Dictionary<string, object> getDataTableFromReply(Post reply)
{
Dictionary<string, object> newReply = new Dictionary<string, object>();
newReply.Add("title", reply.title);
newReply.Add("authorid", reply.author.getID());
newReply.Add("threadid", reply.threadid);
newReply.Add("creationdate", SharedLibrary.Utilities.DateTimeSQLite(reply.creationDate));
newReply.Add("updateddate", SharedLibrary.Utilities.DateTimeSQLite(reply.updatedDate));
newReply.Add("content", reply.content);
newReply.Add("visible", Convert.ToInt32(reply.visible));
return newReply;
}
private Post getReplyFromDataTable(DataTable Result)
{
if (Result != null && Result.Rows.Count > 0)
{
DataRow ResponseRow = Result.Rows[0];
int id = Convert.ToInt32(ResponseRow["id"].ToString());
int threadid = Convert.ToInt32(ResponseRow["threadid"].ToString());
int authorid = Convert.ToInt32(ResponseRow["authorid"].ToString());
string title = ResponseRow["title"].ToString();
var author = getUser(authorid);
DateTime creationDate = DateTime.Parse(ResponseRow["creationdate"].ToString());
DateTime updatedDate = DateTime.Parse(ResponseRow["updateddate"].ToString());
string content = ResponseRow["content"].ToString();
bool visible = Convert.ToBoolean((Convert.ToInt32(ResponseRow["visible"])));
Post retrievedPost = new Post(id, threadid, visible, title, content, author, creationDate, updatedDate);
return retrievedPost;
}
return null;
}
// we have no other unique id yet
private int getReplyID(DateTime creationDate)
{
DataTable Result = GetDataTable("REPLIES", new KeyValuePair<string, object>("creationdate", SharedLibrary.Utilities.DateTimeSQLite(creationDate)));
if (Result != null && Result.Rows.Count > 0)
return Convert.ToInt32(Result.Rows[0]["id"].ToString());
return 0;
}
#endregion
#region PROFILES
private ProfileSettings getProfileFromDataTable(DataTable Result)
{
if (Result != null && Result.Rows.Count > 0)
{
DataRow ResponseRow = Result.Rows[0];
int id = Convert.ToInt32(ResponseRow["id"].ToString());
int userID = Convert.ToInt32(ResponseRow["userid"].ToString());
bool showEmail = Convert.ToBoolean(Convert.ToInt32(ResponseRow["showemail"].ToString()));
string bannerColor = ResponseRow["bannercolor"].ToString();
DateTime birthday = DateTime.Parse(ResponseRow["birthday"].ToString());
bool showAge = Convert.ToBoolean(Convert.ToInt32(ResponseRow["showage"].ToString()));
ProfileSettings foundProfile = new ProfileSettings(id, userID, showEmail, bannerColor, birthday, showAge);
return foundProfile;
}
return null;
}
private Dictionary<string, object> getDataTableFromProfile(ProfileSettings addedSettings)
{
Dictionary<String, object> newSettings = new Dictionary<String, object>();
if(addedSettings.id > 0)
newSettings.Add("id", addedSettings.id);
newSettings.Add("userid", addedSettings.userid);
newSettings.Add("showemail", Convert.ToInt32(addedSettings.showEmail));
newSettings.Add("bannercolor", addedSettings.bannerColor);
newSettings.Add("birthday", SharedLibrary.Utilities.DateTimeSQLite(addedSettings.birthday));
newSettings.Add("showage", Convert.ToInt32(addedSettings.showAge));
return newSettings;
}
public ProfileSettings getProfileSettings(int userid)
{
DataTable Result = GetDataTable("PROFILES", new KeyValuePair<string, object>("userid", userid));
return getProfileFromDataTable(Result);
}
public bool addProfileSettings(ProfileSettings newProfile)
{
return Insert("PROFILES", getDataTableFromProfile(newProfile));
}
public bool updateProfileSettings(ProfileSettings updatedProfile)
{
return Update("PROFILES", getDataTableFromProfile(updatedProfile), new KeyValuePair<string, object>("userid", updatedProfile.userid));
}
#endregion
}
}

View File

@ -1,152 +0,0 @@
using System;
using System.Collections.Generic;
namespace MessageBoard
{
public class Post : ForumThread
{
/// <summary>
/// Initial creation
/// </summary>
/// <param name="title"></param>
/// <param name="content"></param>
/// <param name="author"></param>
/// <param name="parentThread"></param>
///
public int threadid;
public Post(string title, int threadid, string content, User author) : base (title, content, author, null)
{
this.threadid = threadid;
}
public Post(int id, int threadid, bool visible, string title, string content, User author, DateTime creationDate, DateTime updatedDate) : base(id, title, visible, content, 0, author, null, creationDate, updatedDate)
{
this.lastModificationString = SharedLibrary.Utilities.GetTimePassed(creationDate);
this.threadid = threadid;
}
}
public class Category : Identifiable
{
public int id { get; private set; }
public string title { get; private set; }
public string description { get; private set; }
public List<Permission> permissions { get; private set; }
public Category(string title, string description)
{
this.title = title;
this.description = description;
this.permissions = new List<Permission>();
id = 0;
}
public Category(int id, string title, string description, List<Permission> permissions)
{
this.title = title;
this.description = description;
this.id = id;
this.permissions = permissions;
}
public int getID()
{
return id;
}
}
public class ForumThread : Identifiable
{
public string title { get; private set; }
public string content { get; private set; }
public string formattedContent { get; private set; }
public User author { get; private set; }
public Category threadCategory { get; private set; }
public DateTime creationDate { get; private set; }
public DateTime updatedDate;
public string lastModificationString { get; protected set; }
public int id { get; private set; }
public int replies;
public bool visible = true;
/// <summary>
/// Initial creation
/// </summary>
/// <param name="title"></param>
/// <param name="content"></param>
/// <param name="author"></param>
public ForumThread(string title, string content, User author, Category threadCategory)
{
if (content.Length == 0)
throw new Exceptions.ThreadException("Post is empty");
if (author == null)
throw new Exceptions.ThreadException("No author of post");
if (title.Length == 0)
throw new Exceptions.ThreadException("Title is empty");
this.title = title;
this.content = content;
this.author = author;
this.threadCategory = threadCategory;
creationDate = DateTime.Now;
updatedDate = DateTime.Now;
replies = 0;
id = 0;
}
/// <summary>
/// Loading from database
/// </summary>
/// <param name="id"></param>
/// <param name="title"></param>
/// <param name="content"></param>
/// <param name="author"></param>
/// <param name="creationDate"></param>
public ForumThread(int id, string title, bool visible, string content, int replies, User author, Category threadCategory, DateTime creationDate, DateTime updatedDate)
{
this.id = id;
this.replies = replies;
this.title = title;
this.content = content;
this.formattedContent = CodeKicker.BBCode.BBCode.ToHtml(this.content);
this.author = author;
this.threadCategory = threadCategory;
this.creationDate = creationDate;
this.updatedDate = updatedDate;
this.lastModificationString = SharedLibrary.Utilities.GetTimePassed(updatedDate);
this.visible = visible;
}
public int getID()
{
return id;
}
public bool updateContent(string content)
{
if (content != null && content.Length > 0)
{
this.content = content;
return true;
}
return false;
}
public bool updateTitle(string title)
{
if (title != null && title.Length > 0)
{
this.title = title;
return true;
}
return false;
}
}
}

View File

@ -1,168 +0,0 @@
using System;
using System.Collections.Generic;
using SharedLibrary;
namespace MessageBoard
{
public class User : Identifiable
{
private string passwordHash; // byte array -> b64 string
private string passwordSalt; // byte array -> b64 string
public DateTime lastLogin;
public string lastLoginString;
public readonly DateTime creationDate;
public int id { get; private set; }
public string avatarURL;
public string username { get; private set; }
public string email { get; private set; }
public Rank ranking;
public int posts;
public int privateMessages;
public int warnings;
public List<int> subscribedThreads { get; private set; }
public User()
{
username = "Guest";
ranking = Plugin.Main.ManagerInstance.guestRank;
}
/// <summary>
/// When creating a new user
/// </summary>
/// <param name="username"></param>
/// <param name="email"></param>
/// <param name="passwordHash"></param>
/// <param name="passwordSalt"></param>
/// <param name="posts"></param>
/// <param name="privateMessage"></param>
/// <param name="warnings"></param>
public User(string username, string matchedUsername, string email, string passwordHash, string passwordSalt, Rank ranking)
{
if (username.Length < 1)
throw new Exceptions.UserException("Username is empty");
if (email.Length < 1)
throw new Exceptions.UserException("Email is empty");
lastLogin = DateTime.Now;
subscribedThreads = new List<int>();
this.username = username;
this.email = email;
this.posts = 0;
this.privateMessages = 0;
this.warnings = 0;
this.ranking = ranking;
this.passwordHash = passwordHash;
this.passwordSalt = passwordSalt;
this.creationDate = DateTime.Now;
this.avatarURL = "";
id = 0;
}
public User(int id, string passwordHash, string passwordSalt, string username, string email, int posts, DateTime lastLogin, DateTime creationDate, Rank ranking, string avatarURL)
{
this.id = id;
this.passwordHash = passwordHash;
this.passwordSalt = passwordSalt;
this.username = username;
this.email = email;
this.lastLogin = lastLogin;
this.creationDate = creationDate;
this.ranking = ranking;
this.avatarURL = avatarURL;
this.posts = posts;
this.lastLoginString = SharedLibrary.Utilities.GetTimePassed(lastLogin);
}
public int getID()
{
return this.id;
}
public string getPasswordSalt()
{
return this.passwordSalt;
}
public string getPasswordHash()
{
return this.passwordHash;
}
public void updateUsername(string username)
{
if (username != null && username.Length > 0)
this.username = username;
}
public void updateAvatar(string avatarURL)
{
this.avatarURL = avatarURL;
}
public void updatePassword(string salt, string hash)
{
if (salt.Length > 0 && hash.Length > 0)
{
passwordHash = hash;
passwordSalt = salt;
}
}
}
public class ProfileSettings
{
public int id { get; private set; }
public int userid { get; private set; }
public bool showEmail { get; private set; }
public string bannerColor;
public DateTime birthday { get; private set; }
public bool showAge { get; private set; }
public ProfileSettings(int userid)
{
id = 0;
this.userid = userid;
showEmail = true;
showAge = true;
}
public ProfileSettings(int id, int userid, bool showEmail, string bannerColor, DateTime birthday, bool showAge)
{
this.id = id;
this.userid = userid;
this.showEmail = showEmail;
this.bannerColor = bannerColor;
this.birthday = birthday;
this.showAge = showAge;
}
public void hideEmail(bool shouldHide)
{
if (shouldHide)
showEmail = false;
else
showEmail = true;
}
public void hideAge(bool shouldHide)
{
if (shouldHide)
showAge = false;
else
showAge = true;
}
}
public struct UserInfo
{
public User user;
public ProfileSettings profile;
}
}

View File

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.0.1" newVersion="4.0.0.1"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>

View File

@ -1,86 +0,0 @@
<div id="view">
<div style="float: left;" id="categoryHeader">
</div>
<a href="home"><i class="fa fa-reply themeBlue" aria-hidden="true" style="padding: 0 0.5em; font-size: 24pt; cursor: pointer; margin-top: -5px;"></i></a>
<a href="" id="postThreadButton">
<div style="float: right;" id="postThreadCaption">
<i class="fa fa-plus" aria-hidden="true"></i>
Post
</div>
</a>
<div style="clear: both;"></div>
<hr class="simple"/>
<div id="categoryContainer">
</div>
<hr/>
</div>
<script>
$('#postThreadButton').attr("href", "postthread?id=" + parseGet("id"));
$( document ).on("actionEventLoad", function() {
$.getJSON("_categorythreads?id=" + parseGet("id"), function(response) {
var result = "";
if (response.errorCode != null)
{
if (response.errorCode == 1)
$('#categoryHeader').append('Permission Denied');
else if (response.errorCode == 13)
{
$('#categoryHeader').html("Invalid Category");
$('#postThreadButton').hide();
}
return;
}
if (response.length == 0)
{
$('#categoryHeader').append('No Posts');
return;
}
$.each(response, function(i, thread) {
result +=
"<div class=\"categoryThread table\"> \
<i class=\"fa fa-circle-o themeBlue tableCell\" aria-hidden=\"true\"></i> \
<div class=\"threadTitle tableCell\"><a href=\"thread?id=" + thread["id"] + "\">" + decodeURIComponent(thread["title"]) + "</a><span class=\"threadAuthor tableCell\"><a href=\"user?id=" + thread["author"].id + "\">" + thread["author"].username + "</a></span></div> \
<div class=\"threadTime tableCell\">Last response " + checkJustNow(thread["lastModificationString"]) + "</div> \
<div class=\"threadReplyCount tableCell\"><div class=\"threadReplyBG\">"+ thread.replies +"</div></div> \
<div class=\"threadActions tableCell\" style='vertical-align: middle; " + shouldHideAction(thread.author) +"'><i postid='"+ thread.id + "' class=\"fa fa-times actionHover actionDelete\" aria-hidden=\"true\"></i></div>\
</div>";
});
$('#categoryHeader').html(response[0]["threadCategory"].title);
$('#categoryContainer').append(result);
});
});
$('#content').on('click', '.actionDelete', function(e) {
$.getJSON("_editthread",
{
id : $(this).attr("postid"),
delete : true
},
function(response) {
if (response.success)
window.location.replace(response.destination);
});
});
</script>
<!--
<div id="categoryContainer">
<div class="categoryThread table">
<i class="fa fa-circle-o themeBlue tableCell" aria-hidden="true"></i>
<div class="threadTitle tableCell"><a href="#">This is the particular thread title</a><span class="threadAuthor tableCell"><a href="#">Example Author</a></span></div>
<div class="threadTime tableCell">5 minutes ago</div>
<div class="threadReplyCount tableCell"><div class="threadReplyBG">0</div></div>
</div>-->

View File

@ -1,60 +0,0 @@
<div id="view" class="table">
<div id="threadView" class="tableCell">
<div class="threadBox">
</div>
<hr/>
</div>
<div id="recentView" class="tableCell">
<div id="recentTitle">
Online Users
</div>
<div id="onlineUsers">
</div>
</div>
</div>
<script>
$( document ).ready(function() {
$.getJSON("_recentthreads", function(response) {
var result = "";
$.each(response, function(i, category) {
result += "<div class=\"categoryTitle datThing\"> \
<div class=\"title\"><a href=\"category?id=" + category["categoryID"] + "\">" + category["categoryTitle"] + "</a></div> \
<div class=\"categoryDescription\">" + category["categoryDescription"] + "</div>" +
"</div> \
<div class=\"threadPreview table\">";
$.each(category["recentThreads"], function(i, thread)
{
result += "<div class=\"individualThreadInfo\">";
result += "<i class=\"fa fa-comment\" aria-hidden=\"true\"></i>";
result += "<span class=\"threadTitle tableCell\"><a href=\"thread?id=" + thread.id + "\">" + decodeURIComponent(thread.title) + "</a> &mdash; <a style='opacity: 0.5;' href=\"user?id=" + thread.author.id + "\">" + thread.author['username'] + "</a></span>";
result += "<span class=\"threadInfo tableCell\"><a class=\"themeOrange\" href=\"" + "user?id=" + thread.author['id'] + "\"></a><span class=\"light\">" + checkJustNow(thread.lastModificationString) + "</span></span>";
result += "<div style=\"display: table-row;\"></div>";
result += "</div>";
});
result += "</div>"
});
$('.threadBox').append(result);
});
$.getJSON("_stats", function(response) {
$.each(response.onlineUsers, function(i, user) {
$('#onlineUsers').append('<a href="user?id=' + user.id + '"><p>' + getColorForLevel(user.ranking.name, user.username) + '<p></a>');
});
});
});
</script>

View File

@ -1,59 +0,0 @@
<div class="infoBox" style="display : none;">
<div class="header">
<i class="fa fa-user" aria-hidden="true"></i>
Login</div>
<div class="alertBox">
</div>
<form id="login" method="get">
<input id="username" name="username" type="text"/>
<label for="username">Username</label>
<input id="password" name="password" type="password"/>
<label for="password">Password</label>
<input id="loginButton" value="Login" type="submit"/>
<a href="register">Register</a>
</form>
</div>
<script>
$( document ).ready(function() {
checkPrivilege();
});
function validateInput()
{
var password = $('form #password');
var username = $('form #username');
if (password.val().length < 1) {
showErrorMessage("Password is required!");
return false;
}
if (username.val().length < 1) {
showErrorMessage("Username is required!");
return false;
}
return true;
}
$("#loginButton").click(function(e) {
e.preventDefault();
if (validateInput())
$.getJSON("_login",
{
username : $('form #username').val(),
password : $('form #password').val()
},
function(result) {
if (result["errorCode"] == 0)
window.location.replace(result["destination"]);
else {
showErrorMessage(result["errorCode"]);
}
}
);
});
</script>

View File

@ -1,56 +0,0 @@
<div id="postThreadContainer">
<div class="infoBox" style="width: 80%;">
<div class="header">
<i class="fa fa-commenting" aria-hidden="true"></i>
<span>Post New Thread</span>
</div>
<div class="alertBox">
</div>
<form>
<div class="table" style="width: 100%;">
<select id="threadCategory" class="tableCell">
</select>
<input placeholder="Enter thread title..." type="text" id="threadTitle" class="tableCell"/>
</div>
<textarea id="threadContent" placeholder="Enter thread content..."/></textarea>
<input type="submit" value="Post" id="submitThreadButton"/>
</form>
</div>
</div>
<script>
$( document ).ready(function() {
$.getJSON("_categories", function(response) {
$.each(response, function(i, category) {
$('select').append("<option value='" + category.id + "'>" + category.title + "</option>");
});
$('select option[value="'+ parseGet("id") +'"]').attr("selected",true);
});
});
$("#submitThreadButton").click(function(e) {
e.preventDefault();
$.getJSON("_postthread",
{
title : $('form #threadTitle').val(),
content : $('form #threadContent').val(),
category : $('select').val(),
},
function(result) {
if (result["errorCode"] == 0)
window.location.replace(result["destination"]);
else {
showErrorMessage(result["errorCode"]);
}
}
);
});
</script>

View File

@ -1,92 +0,0 @@
<div class="infoBox" style="display:none;">
<div class="header">
<i style="" class="fa fa-user-plus" aria-hidden="true"></i>
Register
</div>
<div class="alertBox">
</div>
<form id="registration" method="get">
<input id="username" name="username" type="text"/>
<input id="hiddenUsername" type="text" name="hiddenUsername" style="display: none;"/>
<label for="username">Username</label>
<input id="password" name="password" type="password"/>
<label for="password">Password</label>
<input id="passwordRepeat" name="passwordRepeat" type="password"/>
<label for="passwordRepeat">Verify Password</label>
<input id="email" name="email" type="text"/>
<label for="email">Email</label>
<input id="registerButton" value="Register" type="submit"/>
</form>
</div>
<script>
$( document ).ready(function() {
checkPrivilege();
});
function validateInput()
{
var password = $('form #password');
var repeatPassword = $('form #passwordRepeat');
var username = $('form #username');
var email = $('form #email');
if (password.val().length < 5) {
showErrorMessage("Passwords must be at least 5 characters!");
return false;
}
if (password.val() != repeatPassword.val()) {
showErrorMessage("Passwords must match!");
return false;
}
if (username.val().length < 3) {
showErrorMessage("Username must contain at least 3 characters!");
return false;
}
if (email.val().length < 3) {
showErrorMessage("Invalid email address!");
return false;
}
return true;
}
$("#registerButton").click(function(e) {
e.preventDefault();
if (validateInput())
$.getJSON("_register",
{
username : $('form #username').val(),
password : $('form #password').val(),
hiddenUsername : $('form #hiddenUsername').val(),
passwordRepeat : $('form #passwordRepeat').val(),
email : $('form #email').val()
},
function(result) {
if (result["errorCode"] == 0)
window.location.replace(result["destination"]);
else {
showErrorMessage(result["errorCode"]);
}
}
);
});
$('input[type="text"], input[type="password"]').click(function() { $('.alertBox').slideUp("fast"); });
$( document ).ready(function() {
$.getJSON("_userinfo", function(result) {
if (result["matchedName"] != "null")
$('#username, #hiddenUsername').val(result["matchedUsername"]);
});
});
</script>

View File

@ -1,209 +0,0 @@
<div id="threadContainer">
<div id="textNav"><a class="themeBlue" href="home">Home</a> &raquo; </div>
<hr />
<div class="threadStart table" style="width: 100%;">
<div class="userInfo tableCell">
<div class="userAvatar">
<i class="fa fa-user-secret" aria-hidden="true" style="font-size: 8em;"></i>
</div>
<a class="userProfileLink" href=""><span class="userTitle">_</span></a><br />
<span style="font-size: 9pt;" class="timePosted">_</span>
</div>
<div class="threadInfo tableCell">
<div class="threadTitle" style="float: left;">_</div>
<div style="float: right;" id="replyThreadCaption">
<i class="fa fa-reply" aria-hidden="true"></i>
Reply
</div>
<div style="clear: both;"></div>
<div style="float: right; display: none;" id="editThreadCaption">
<i class="fa fa-pencil-square-o" aria-hidden="true"></i>
Edit
</div>
<div class="threadContent">_</div>
</div>
</div>
</div>
<div id="postReplyContainer" style="display: none;">
<hr />
<div id="postReplyClose">
<i class="fa fa-times" aria-hidden="true"></i>
</div>
<div id="replyContentContainer">
<div class="alertBox">
</div>
<textarea placeholder="Reply content..." id="replyContentBox"></textarea>
<div id="submitReplyButton">
<i class="fa fa-reply" aria-hidden="true"></i>
</div>
</div>
</div>
<script>
$( document ).on("actionEventLoad", function() {
$.getJSON("_thread?id=" + parseGet('id'), function(Response) {
if (Response.errorCode != null)
{
alert('error!');
}
$('#textNav').append('<a class="themeBlue" href="category?id=' + Response.Thread.threadCategory.id + '">' + Response.Thread.threadCategory.title + '</a> &raquo; ' + decodeURIComponent(Response.Thread.title));
$('.threadStart .userTitle').html(Response.Thread.author.username);
$('.threadStart .timePosted').html(getDate(Response.Thread.creationDate));
$('.threadStart .threadTitle').html(Response.Thread.title);
$('.threadStart a.userProfileLink').attr("href", "user?id=" + Response.Thread.author.id);
$('.threadStart .threadContent').html(Response.Thread.formattedContent);
if (Response.Thread.author.avatarURL != "")
$('.threadStart .userAvatar').html("").attr("style", "background-image:url('" + Response.Thread.author.avatarURL + "');'");
$('#replyThreadButton').attr("href", "postthread?threadid=" + Response.Thread.id);
if (user.user.id == Response.Thread.author.id)
$('#editThreadCaption').css("display", "block");
$.each(Response.Replies, function(i, eachReply) {
var cat = "<div class='threadStart table' style='width: 100%;'> \
<div class='userInfo tableCell'>";
if (eachReply.author.avatarURL == "")
cat += "<div class='userAvatar'><i class='fa fa-user-secret' aria-hidden='true' style='font-size: 8em;'></i>";
else
cat += "<div class='userAvatar' style=\"background-image:url('" + eachReply.author.avatarURL + "');\">";
cat +=
"</div> \
<a class='userProfileLink' href='user?id="+ eachReply.author.id +"'><span class='userTitle'>" + getColorForLevel(eachReply.author.ranking.name, eachReply.author.username) + "</span></a><br/> \
<span style='font-size: 9pt;' class='timePosted'>" + checkJustNow(eachReply.lastModificationString) + "</span> \
</div> \
<div class='threadInfo tableCell'> \
<i style=\"" + shouldHideAction(eachReply.author) + "\" replyid='" + eachReply.id + "' class=\"fa fa-times actionHover actionDelete\" aria-hidden=\"true\"></i> \
<i style=\"" + shouldHideAction(eachReply.author) + "\" replyid='" + eachReply.id + "' class=\"fa fa-pencil-square-o actionHover actionEdit\" aria-hidden=\"true\"></i> \
<div class='threadContent'>" + decodeURIComponent(eachReply.formattedContent) + "</div> \
</div> \
</div>";
$("#threadContainer").append(cat);
});
});
});
$('#replyThreadCaption').click(function(e) {
e.preventDefault();
$('#postReplyContainer').slideDown('fast');
});
$('#postReplyClose').click(function(e) {
$(this).parent().slideUp('fast');
});
$("#submitReplyButton").click(function(e) {
e.preventDefault();
if ($('#postReplyContainer').attr("editthread") == "true") {
$.getJSON("_editthread",
{
content : $('#replyContentBox').val(),
title : $('#postReplyContainer').attr("threadtitle"),
id : parseGet("id"),
update: true
},
function(result) {
if (result["errorCode"] == 0)
window.location.replace(result["destination"]);
else {
showErrorMessage(result["errorCode"]);
}
});
}
else if ($('#postReplyContainer').attr("editreply") != "true") {
$.getJSON("_postthread",
{
content : $('#replyContentBox').val(),
title : "Reply",
threadid : parseGet("id")
},
function(result) {
if (result["errorCode"] == 0)
window.location.replace(result["destination"]);
else {
showErrorMessage(result["errorCode"]);
}
});
}
else {
$.getJSON("_editthread",
{
content : $('#replyContentBox').val(),
title : "Reply",
replyid : $('#postReplyContainer').attr("replyid"),
threadid : parseGet("id")
},
function(result) {
if (result["errorCode"] == 0)
window.location.replace(result["destination"]);
else {
showErrorMessage(result["errorCode"]);
}
});
}
});
$('#content').on('click', '.actionDelete', function(e) {
$.getJSON("_editthread",
{
replyid : $(this).attr("replyid"),
delete : true
},
function(response) {
if (response.success)
window.location.replace(response.destination);
});
});
$('#content').on('click', '.actionEdit', function (e) {
$('#postReplyContainer').slideDown('fast');
var id = $(this).attr("replyID")
$.getJSON("_thread?replyid=" + id, function(Response) {
$('#postReplyContainer').find("textarea").html(Response.content);
$('#postReplyContainer').attr("editReply", true);
$('#postReplyContainer').attr("replyid", id);
});
/*$.getJSON("_editthread",
{
replyid: $(this).attr("replyid"),
delete: false
},
function (response) {
if (response.success)
window.location.replace(response.destination);
});*/
});
$("#editThreadCaption").click(function(e) {
$('#postReplyContainer').slideDown('fast');
$.getJSON("_thread?id=" + parseGet("id"), function(Response) {
$('#postReplyContainer').find("textarea").html(Response.Thread.content);
$('#postReplyContainer').attr("editthread", true);
$('#postReplyContainer').attr("threadid", parseGet("id"));
$('#postReplyContainer').attr("threadtitle", Response.Thread.title);
});
});
</script>

View File

@ -1,62 +0,0 @@
<div id="userCover" style="display:none;">
</div>
<div id="userInfoBox">
<div class="table" style="width: 100%;">
<div class="tableCell" style="vertical-align:middle; width: 70%;">
<div class="userInfoField table">
<i class="fa fa-user tableCell" aria-hidden="true"></i> <span class="tableCell" id="userCreated">_</span>
</div>
<div class="userInfoField table">
<i class="fa fa-clock-o tableCell" aria-hidden="true"></i> <span class="tableCell" id="userLogon">_</span>
</div>
<div class="userInfoField table">
<i class="fa fa-comment tableCell" aria-hidden="true"></i> <span class="tableCell" id="userPostCount">_</span>
</div>
<div class="userInfoField table">
<i class="fa fa-envelope-o tableCell" aria-hidden="true"></i> <span class="tableCell" id="userEmail"><a href="#" class="themeBlue">_</a></span>
</div>
<div class="userInfoField table">
<i class="fa fa-users tableCell" aria-hidden="true"></i> <span class="tableCell" id="userRank">_</span>
</div>
</div>
<div class="tableCell" style="vertical-align:middle;">
<div id="userAvatar" class="">
<i class="fa fa-user-secret" aria-hidden="true" style="font-size: 19em; margin-top: -56px;"></i>
</div>
</div>
</div>
<hr style="width: calc(100% + 2em); margin-bottom: -1em; margin-left: -1em;" />
</div>
<div style="width: 100%; text-align: center; margin: 1em 0;"><a href="usercp">User Control Panel</a></div>
<script>
$.getJSON("_userinfo?id=" + parseGet('id'), function (Response) {
var user = Response.user;
if (user == null)
return false;
$('#userCover').html(user.username);
$('#userCover').css("background-color", Response.profile.bannerColor);
var creationDate = new Date(user.creationDate);
$('#userCreated').html("Joined " + (creationDate.getMonth() + 1) + '-' + creationDate.getDate() + '-' + creationDate.getFullYear());
$('#userLogon').html("Last seen " + user.lastLoginString);
$('#userPostCount').html(user.posts + " Posts");
if (Response.profile.showEmail) {
$('#userEmail a').html(user.email);
$('#userEmail a').attr("href", "mailto:" + user.email);
}
$('#userAvatar').html('');
$('#userAvatar').attr("style", "background-image:url('" + user.avatarURL + "');'");
$('#userRank').html(user.ranking.name);
$('#userCover').slideDown('fast');
});
</script>

View File

@ -1,64 +0,0 @@
<div class="alertBox">
</div>
<form id="userCP">
<div class="table">
<div class="tableCell">
<span style="display:flex; margin: 0.25em;">Username</span>
<input type="text" name="username" id="username" />
</div>
<div class="tableCell">
<span style="display:flex; margin: 0.25em;">Banner Color</span>
<input type="color" name="bannercolor" id="bannercolor" />
</div>
</div>
<div class="table">
<div class="tableCell">
<span style="display:flex; margin: 0.25em;">New Password</span>
<input type="password" name="updatedpassword" id="updatedpassword"/>
</div>
<div class="table">
<span style="display:flex; margin: 0.25em;">Repeat New Password</span>
<input type="password" name="updatedpasswordrepeat" id="updatedpasswordrepeat" />
</div>
</div>
<div id="userAvatar" style="margin: 1em 0;">
</div>
<span style="display:flex; margin: 0.25em;">Avatar URL</span>
<input style="width: 35%;" type="text" id="avatarurl" name="avatarurl" /><br />
<input id="updateprofile" type="submit" name="submit" value="Update" />
</form>
<script>
$.getJSON("_userinfo", function(result) {
$("#userAvatar").css('background-image', "".concat("url(", result.user['avatarURL'], ")"));
$("#username").val(result.user.username);
$("#bannercolor").val(result.profile.bannerColor);
$("#avatarurl").val(result.user.avatarURL);
});
$('#updateprofile').click(function (e) {
if (user.id == 0)
return false;
e.preventDefault();
$.getJSON("_updateuser",
{
username : $('#username').val(),
bannercolor : $('#bannercolor').val(),
avatarurl : $('#avatarurl').val(),
updatedpassword : $('#updatedpassword').val(),
updatedpasswordrepeat: $('#updatedpasswordrepeat').val()
},
function(result) {
if (result["errorCode"] == 0)
window.location.replace(result["destination"]);
else {
showErrorMessage(result["errorCode"]);
}
});
});
</script>

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CodeKicker.BBCode" version="5.0.0.0" targetFramework="net45" />
<package id="CryptSharp" version="1.2.0.1" targetFramework="net45" />
<package id="DNA.Text" version="2.1.1.10633" targetFramework="net45" />
<package id="Newtonsoft.Json" version="10.0.2" targetFramework="net45" />
</packages>

View File

@ -0,0 +1,36 @@
using SharedLibrary.Interfaces;
using System;
using System.Collections.Generic;
using System.Text;
using SharedLibrary;
namespace ProfanityDeterment
{
class Configuration : IBaseConfiguration
{
public List<string> OffensiveWords { get; set; }
public bool EnableProfanityDeterment { get; set; }
public string ProfanityWarningMessage { get; set; }
public string ProfanityKickMessage { get; set; }
public int KickAfterInfringementCount { get; set; }
public IBaseConfiguration Generate()
{
OffensiveWords = new List<string>()
{
"nigger",
"nigga",
"fuck"
};
EnableProfanityDeterment = Utilities.PromptBool("Enable profanity deterring");
ProfanityWarningMessage = "Please do not use profanity on this server";
ProfanityKickMessage = "Excessive use of profanity";
KickAfterInfringementCount = 2;
return this;
}
public string Name() => "Configuration";
}
}

View File

@ -0,0 +1,90 @@
using System;
using System.Collections.Concurrent;
using System.Linq;
using System.Threading.Tasks;
using SharedLibrary;
using SharedLibrary.Configuration;
using SharedLibrary.Interfaces;
namespace ProfanityDeterment
{
public class Plugin : IPlugin
{
public string Name => "ProfanityFilter";
public float Version => 0.1f;
public string Author => "RaidMax";
BaseConfigurationHandler<Configuration> Settings;
ConcurrentDictionary<int, Tracking> ProfanityCounts;
IManager Manager;
Task CompletedTask = Task.FromResult(false);
public async Task OnEventAsync(Event E, Server S)
{
if (E.Type == Event.GType.Connect)
{
if (!ProfanityCounts.TryAdd(E.Origin.ClientId, new Tracking(E.Origin)))
{
S.Logger.WriteWarning("Could not add client to profanity tracking");
}
}
if (E.Type == Event.GType.Disconnect)
{
if (!ProfanityCounts.TryRemove(E.Origin.ClientId, out Tracking old))
{
S.Logger.WriteWarning("Could not remove client from profanity tracking");
}
}
if (E.Type == Event.GType.Say)
{
var objectionalWords = Settings.Configuration().OffensiveWords;
bool containsObjectionalWord = objectionalWords.FirstOrDefault(w => E.Data.ToLower().Contains(w)) != null;
if (containsObjectionalWord)
{
var clientProfanity = ProfanityCounts[E.Origin.ClientId];
if (clientProfanity.Infringements >= Settings.Configuration().KickAfterInfringementCount)
{
await clientProfanity.Client.Kick(Settings.Configuration().ProfanityKickMessage, new SharedLibrary.Objects.Player()
{
ClientId = 1
});
}
else if (clientProfanity.Infringements < Settings.Configuration().KickAfterInfringementCount)
{
clientProfanity.Infringements++;
await clientProfanity.Client.Warn(Settings.Configuration().ProfanityWarningMessage, new SharedLibrary.Objects.Player()
{
ClientId = 1
});
}
}
}
}
public async Task OnLoadAsync(IManager manager)
{
// load custom configuration
Settings = new BaseConfigurationHandler<Configuration>("ProfanityDetermentSettings");
if (Settings.Configuration() == null)
{
Settings.Set((Configuration)new Configuration().Generate());
await Settings.Save();
}
ProfanityCounts = new ConcurrentDictionary<int, Tracking>();
Manager = manager;
}
public Task OnTickAsync(Server S) => CompletedTask;
public Task OnUnloadAsync() => CompletedTask;
}
}

View File

@ -4,12 +4,12 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{1479DE87-ACB5-4046-81C8-A0BA5041227D}</ProjectGuid>
<ProjectGuid>{3EA31029-C76F-4C8E-AFD4-79F77DEA7033}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>FastRestartPlugin</RootNamespace>
<AssemblyName>FastRestartPlugin</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<RootNamespace>ProfanityDeterment</RootNamespace>
<AssemblyName>ProfanityDeterment</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
@ -21,7 +21,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release-Nightly|AnyCPU' ">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
@ -30,45 +30,44 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release-Nightly|x86' ">
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<OutputPath>bin\x86\Release\</OutputPath>
<Optimize>true</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release-Stable|AnyCPU'">
<OutputPath>bin\Release-Stable\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release-Stable|x86'">
<OutputPath>bin\x86\Release-Stable\</OutputPath>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<Optimize>false</Optimize>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Configuration.cs" />
<Compile Include="Plugin.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Tracking.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\SharedLibrary\SharedLibrary.csproj">
<Project>{d51eeceb-438a-47da-870f-7d7b41bc24d6}</Project>
<Name>SharedLibrary</Name>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

View File

@ -5,12 +5,12 @@ using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("FastRestartPlugin")]
[assembly: AssemblyTitle("ProfanityDeterment")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FastRestartPlugin")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyProduct("ProfanityDeterment")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@ -20,7 +20,7 @@ using System.Runtime.InteropServices;
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("1479de87-acb5-4046-81c8-a0ba5041227d")]
[assembly: Guid("3ea31029-c76f-4c8e-afd4-79f77dea7033")]
// Version information for an assembly consists of the following four values:
//

View File

@ -0,0 +1,19 @@
using SharedLibrary.Objects;
using System;
using System.Collections.Generic;
using System.Text;
namespace ProfanityDeterment
{
class Tracking
{
public Player Client { get; private set; }
public int Infringements { get; set; }
public Tracking(Player client)
{
Client = client;
Infringements = 0;
}
}
}

View File

@ -1,303 +0,0 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using SharedLibrary;
using SharedLibrary.Network;
using SharedLibrary.Interfaces;
using SharedLibrary.Objects;
namespace Votemap_Plugin
{
/// <summary>
/// Allow clients to vote for the next map at the end of a round
/// Map choices are defined in the server
/// </summary>
public class VoteMap : Command
{
public VoteMap() : base("vote", "vote for the next map", "v", Player.Permission.User, false, new CommandArgument[]
{
new CommandArgument()
{
Name = "map",
Required = true
}
})
{ }
/// <summary>
/// Properties of Event E
/// Owner: The server the event came from
/// Origin: The player generating the event
/// Target: Optional target the player specified
/// Data: Chat message which triggered the command event
/// </summary>
/// <param name="E">This is the `say` event that comes from the server</param>
public override async Task ExecuteAsync(Event E)
{
var voting = Vote.GetServerVotes(E.Owner.GetPort());
// we only want to allow a vote during a vote session
if (voting.voteInSession)
{
if (voting.ClientHasVoted(E.Origin.NetworkId.ToString()))
await E.Origin.Tell("You have already voted. Use ^5!vc ^7to ^5cancel ^7your vote");
else
{
string mapSearch = E.Data.ToLower().Trim();
// probably not the most optimized way to match the map.. but nothing is time critical here
Map votedMap = E.Owner.Maps.Find(m => (m.Alias.ToLower().Contains(mapSearch) || m.Name.Contains(mapSearch)));
if (votedMap == null)
await E.Origin.Tell("^1" + E.Data + " is not a recognized map");
else
{
voting.CastClientVote(E.Origin.NetworkId.ToString(), votedMap);
await E.Origin.Tell("You voted for ^5" + votedMap.Alias);
}
}
}
else
await E.Origin.Tell("There is no vote in session");
}
}
public class VoteCancel : Command
{
public VoteCancel() : base("votecancel", "cancel your vote for the next map", "vc", Player.Permission.User, false) { }
public override async Task ExecuteAsync(Event E)
{
var voting = Vote.GetServerVotes(E.Owner.GetPort());
if (voting.voteInSession)
{
if (voting.ClientHasVoted(E.Origin.NetworkId.ToString()))
{
voting.CancelClientVote(E.Origin.NetworkId.ToString());
await E.Origin.Tell("Vote cancelled");
}
else
{
await E.Origin.Tell("You have no vote to cancel");
}
}
else
await E.Origin.Tell("There is no vote in session");
}
}
public class Vote : IPlugin
{
public class VoteData
{
public string guid;
public Map map;
}
public class MapResult
{
public Map map;
public int voteNum;
}
public class ServerVoting
{
public int ServerId
{
get; private set;
}
public bool voteInSession;
public bool matchEnded;
public bool votePassed;
public bool waitForLoad;
public DateTime voteTimeStart;
public DateTime loadStartTime;
public List<VoteData> VoteList
{
get; private set;
}
public ServerVoting(int id)
{
ServerId = id;
voteInSession = false;
votePassed = false;
matchEnded = false;
waitForLoad = true;
VoteList = new List<VoteData>();
}
public int GetTotalVotes()
{
return VoteList.Count;
}
public bool ClientHasVoted(string guid)
{
return VoteList.Exists(x => (x.guid == guid));
}
public void CastClientVote(string guid, Map map)
{
var vote = new VoteData()
{
guid = guid,
map = map
};
VoteList.Add(vote);
}
public void CancelClientVote(string guid)
{
VoteList.RemoveAll(x => (x.guid == guid));
}
public MapResult GetTopVotedMap()
{
List<MapResult> results = new List<MapResult>();
MapResult result = new MapResult()
{
map = new Map("Remain", "Remain"),
voteNum = 0
};
foreach (var vote in VoteList)
{
if (!results.Exists(x => (x.map.Name == vote.map.Name)))
{
MapResult newResult = new MapResult()
{
map = vote.map,
voteNum = 1
};
results.Add(newResult);
}
else
{
var map = results.Find(x => x.map.Name == vote.map.Name);
map.voteNum += 1;
}
}
foreach (var map in results)
if (map.voteNum > result.voteNum)
result = map;
return result;
}
}
private static List<ServerVoting> serverVotingList;
public static int minVotes = 3;
public string Author => "RaidMax";
public float Version => 1.0f;
public string Name => "Votemap Plugin";
public async Task OnLoadAsync(IManager manager)
{
serverVotingList = new List<ServerVoting>();
}
public async Task OnUnloadAsync()
{
serverVotingList.Clear();
}
/// <summary>
/// The server monitor thread calls this about every 1 second
/// This is not high-precision, but will run 1 time per second
/// </summary>
/// <param name="S"></param>
public async Task OnTickAsync(Server S)
{
var serverVotes = GetServerVotes(S.GetPort());
if (serverVotes != null)
{
if ((DateTime.Now - serverVotes.loadStartTime).TotalSeconds < 30 /* || S.getPlayers().Count < 3*/)
return;
else
serverVotes.waitForLoad = false;
// dvar that is set & updated by the game script...
serverVotes.matchEnded = (await S.GetDvarAsync<int>("scr_gameended")).Value == 1;
/*
Console.WriteLine("===========================");
Console.WriteLine("Match ended->" + serverVotes.matchEnded);
Console.WriteLine("Vote in session->" + serverVotes.voteInSession);
Console.WriteLine("Vote passed->" + serverVotes.votePassed);*/
if (!serverVotes.voteInSession && serverVotes.matchEnded && serverVotes.voteTimeStart == DateTime.MinValue)
{
await S.Broadcast("Voting has started for the ^5next map");
await S.Broadcast("Type ^5!v <map> ^7to vote for the nextmap!");
serverVotes.voteInSession = true;
serverVotes.voteTimeStart = DateTime.Now;
return;
}
if (!serverVotes.voteInSession && serverVotes.votePassed && (DateTime.Now - serverVotes.voteTimeStart).TotalSeconds > 30)
{
await S.LoadMap(serverVotes.GetTopVotedMap().map.Name);
serverVotes.votePassed = false;
return;
}
if (serverVotes.voteInSession)
{
if ((DateTime.Now - serverVotes.voteTimeStart).TotalSeconds > 25)
{
serverVotes.voteInSession = false;
MapResult m = serverVotes.GetTopVotedMap();
await S.Broadcast("Voting has ended!");
if (m.voteNum < minVotes && S.GetPlayersAsList().Count > 4)
await S.Broadcast("Vote map failed. At least ^5" + minVotes + " ^7people must choose the same map");
else
{
await S.Broadcast(String.Format("Next map is ^5{0} ^7- [^2{1}/{2}^7] votes", m.map.Alias, m.voteNum, serverVotes.GetTotalVotes()));
serverVotes.votePassed = true;
}
}
}
}
}
public async Task OnEventAsync(Event E, Server S)
{
if (E.Type == Event.GType.Start)
{
serverVotingList.Add(new ServerVoting(S.GetPort()));
}
if (E.Type == Event.GType.Stop)
{
serverVotingList.RemoveAll(x => x.ServerId == S.GetPort());
}
if (E.Type == Event.GType.MapEnd || E.Type == Event.GType.MapChange)
{
var serverVotes = GetServerVotes(S.GetPort());
serverVotes.VoteList.Clear();
serverVotes.voteTimeStart = DateTime.MinValue;
serverVotes.loadStartTime = DateTime.Now;
serverVotes.waitForLoad = true;
}
}
public static ServerVoting GetServerVotes(int serverID)
{
return serverVotingList.Find(x => (x.ServerId == serverID));
}
}
}

View File

@ -1,88 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{428D8EB9-ECA3-4A66-AA59-3A944378C33F}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Votemap_Plugin</RootNamespace>
<AssemblyName>VotemapPlugin</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release-Nightly|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release-Stable|AnyCPU'">
<OutputPath>bin\Release-Stable\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<PlatformTarget>x86</PlatformTarget>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release-Nightly|x86' ">
<PlatformTarget>x86</PlatformTarget>
<OutputPath>bin\x86\Release\</OutputPath>
<Optimize>true</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release-Stable|x86'">
<PlatformTarget>x86</PlatformTarget>
<OutputPath>bin\x86\Release-Stable\</OutputPath>
<Optimize>true</Optimize>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\SharedLibrary\SharedLibrary.csproj">
<Project>{d51eeceb-438a-47da-870f-7d7b41bc24d6}</Project>
<Name>SharedLibrary</Name>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="Plugin.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>if $(ConfigurationName) == Debug copy /Y "$(TargetDir)$(TargetName).dll" "$(SolutionDir)BUILD\plugins\"</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -390,5 +390,11 @@ namespace SharedLibrary
}
public static bool IsPrivileged(this Player p) => p.Level > Player.Permission.User;
public static bool PromptBool(string question)
{
Console.Write($"{question}? [y/n]: ");
return (Console.ReadLine().ToLower().FirstOrDefault() as char?) == 'y';
}
}
}

View File

@ -26,7 +26,8 @@ namespace WebfrontCore.ViewComponents
.Select(p => new PlayerInfo()
{
Name = p.Name,
ClientId = p.ClientId
ClientId = p.ClientId,
Level = p.Level.ToString()
}).ToList(),
ChatHistory = s.ChatHistory.ToArray()
}).ToList();