So I can work on my desktop
This commit is contained in:
parent
38c8f81051
commit
feb37123e2
@ -11,7 +11,7 @@ namespace IW4MAdmin
|
||||
|
||||
public override void Execute(Event E)
|
||||
{
|
||||
if (E.Owner.owner == null)
|
||||
if (E.Owner.clientDB.getOwner() == null)
|
||||
{
|
||||
E.Origin.setLevel(Player.Permission.Owner);
|
||||
E.Origin.Tell("Congratulations, you have claimed ownership of this server!");
|
||||
|
@ -60,12 +60,9 @@ namespace IW4MAdmin
|
||||
if (S == null)
|
||||
continue;
|
||||
|
||||
if (!isIW4MStillRunning(S.pID()) || !S.isRunning)
|
||||
if (!isIW4MStillRunning(S.pID()))
|
||||
{
|
||||
Thread Defunct = ThreadList[S.pID()];
|
||||
|
||||
if (!S.isRunning)
|
||||
Utilities.shutdownInterface(S.pID());
|
||||
|
||||
S.isRunning = false;
|
||||
if (Defunct != null)
|
||||
@ -73,6 +70,10 @@ namespace IW4MAdmin
|
||||
Defunct.Join();
|
||||
ThreadList[S.pID()] = null;
|
||||
}
|
||||
|
||||
if (!S.isRunning)
|
||||
Utilities.shutdownInterface(S.pID());
|
||||
|
||||
mainLog.Write("Server with PID #" + S.pID() + " can no longer be monitored.", Log.Level.Debug);
|
||||
activePIDs.Remove(S.pID());
|
||||
defunctServers.Add(S);
|
||||
|
@ -16,8 +16,7 @@ namespace IW4MAdmin
|
||||
{
|
||||
commandQueue = new Queue<string>();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void getAliases(List<Aliases> returnAliases, Aliases currentAlias)
|
||||
{
|
||||
foreach(String IP in currentAlias.IPS)
|
||||
@ -47,43 +46,7 @@ namespace IW4MAdmin
|
||||
return allAliases;
|
||||
|
||||
getAliases(allAliases, currentIdentityAliases);
|
||||
return allAliases;
|
||||
|
||||
/*
|
||||
List<Aliases> aliasAliases = new List<Aliases>();
|
||||
Aliases currentAliases = aliasDB.getPlayer(Origin.databaseID);
|
||||
|
||||
if (currentAliases == null)
|
||||
{
|
||||
Log.Write("No aliases found for " + Origin.Name, Log.Level.Debug);
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (String IP in currentAliases.getIPS())
|
||||
{
|
||||
List<Aliases> tmp = aliasDB.getPlayer(IP);
|
||||
if (tmp != null)
|
||||
aliasAliases = tmp;
|
||||
|
||||
foreach (Aliases a in aliasAliases)
|
||||
{
|
||||
if (a == null)
|
||||
continue;
|
||||
|
||||
Player aliasPlayer = clientDB.getPlayer(a.getNumber());
|
||||
|
||||
if (aliasPlayer != null)
|
||||
{
|
||||
aliasPlayer.Alias = a;
|
||||
|
||||
if (returnPlayers.Exists(p => p.databaseID == aliasPlayer.databaseID == false))
|
||||
{
|
||||
returnPlayers.Add(aliasPlayer);
|
||||
getAliases(returnPlayers, aliasPlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
} */
|
||||
return allAliases;
|
||||
}
|
||||
|
||||
//Add player object p to `players` list
|
||||
@ -411,7 +374,7 @@ namespace IW4MAdmin
|
||||
|
||||
override public void setDvar(String Dvar, String Value)
|
||||
{
|
||||
lastDvarPointer = Utilities.executeCommand(PID, Dvar + " " + Value, lastDvarPointer);
|
||||
lastDvarPointer = Utilities.executeCommand(PID, Dvar + " " + "\"" + Value + "\"", lastDvarPointer);
|
||||
}
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
@ -427,6 +390,10 @@ namespace IW4MAdmin
|
||||
if (events.Count > 0)
|
||||
{
|
||||
Event curEvent = events.Peek();
|
||||
|
||||
if (curEvent == null)
|
||||
continue;
|
||||
|
||||
processEvent(curEvent);
|
||||
foreach (Plugin P in PluginImporter.potentialPlugins)
|
||||
{
|
||||
@ -610,6 +577,9 @@ namespace IW4MAdmin
|
||||
{
|
||||
try
|
||||
{
|
||||
// clear out any lingering instances
|
||||
Utilities.shutdownInterface(PID);
|
||||
|
||||
// inject our dll
|
||||
if (!Utilities.initalizeInterface(PID))
|
||||
{
|
||||
@ -646,8 +616,19 @@ namespace IW4MAdmin
|
||||
}
|
||||
|
||||
// our settings
|
||||
setDvar("sv_kickBanTime", "3600"); // 1 hour
|
||||
setDvar("g_logSync", "1"); // yas
|
||||
setDvar("sv_kickbantime", "3600"); // 1 hour
|
||||
|
||||
int logSync = -1;
|
||||
Int32.TryParse(getDvar("g_logSync").current, out oneLog);
|
||||
|
||||
if (logSync == 0)
|
||||
{
|
||||
Log.Write("g_logsync is not set to 1, restarting map...");
|
||||
setDvar("g_logSync", "1"); // yas
|
||||
executeCommand("map_restart");
|
||||
SharedLibrary.Utilities.Wait(10);
|
||||
}
|
||||
|
||||
|
||||
if (Mod == String.Empty || oneLog == 1)
|
||||
logPath = Basepath + '\\' + "m2demo" + '\\' + logPath;
|
||||
@ -799,7 +780,17 @@ namespace IW4MAdmin
|
||||
{
|
||||
Log.Write("New map loaded - " + clientnum + " active players", Log.Level.Debug);
|
||||
|
||||
String newMapName = getDvar("mapname").current;
|
||||
String newMapName = "0";
|
||||
String newGametype = "0";
|
||||
String newHostName = "0";
|
||||
|
||||
while(newMapName == "0" || newGametype == "0" || newHostName == "0") // weird anomaly here.
|
||||
{
|
||||
newMapName = getDvar("mapname").current;
|
||||
newGametype = getDvar("g_gametype").current;
|
||||
newHostName = getDvar("sv_hostname").current;
|
||||
}
|
||||
|
||||
Map newMap = maps.Find(m => m.Name.Equals(newMapName));
|
||||
|
||||
if (newMap != null)
|
||||
@ -807,6 +798,9 @@ namespace IW4MAdmin
|
||||
else
|
||||
mapname = newMapName;
|
||||
|
||||
Gametype = newGametype;
|
||||
hostname = SharedLibrary.Utilities.stripColors(newHostName);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -912,6 +906,8 @@ namespace IW4MAdmin
|
||||
|
||||
commands = new List<Command>();
|
||||
|
||||
owner = clientDB.getOwner();
|
||||
|
||||
if(owner == null)
|
||||
commands.Add(new Owner("owner", "claim ownership of the server", "owner", Player.Permission.User, 0, false));
|
||||
|
||||
|
@ -288,7 +288,7 @@ namespace IW4MAdmin
|
||||
}
|
||||
}
|
||||
|
||||
IntPtr memoryForDvarName = allocateAndWrite(Encoding.ASCII.GetBytes(Command + "\0"), ProcessHandle); // this gets disposed next call
|
||||
IntPtr memoryForDvarName = allocateAndWrite(Encoding.ASCII.GetBytes(Command + '\0'), ProcessHandle); // this gets disposed next call
|
||||
|
||||
if (memoryForDvarName == IntPtr.Zero)
|
||||
{
|
||||
@ -343,49 +343,45 @@ namespace IW4MAdmin
|
||||
return false;
|
||||
}
|
||||
|
||||
IntPtr baseAddress = IntPtr.Zero;
|
||||
List<IntPtr> baseAddresses = new List<IntPtr>();
|
||||
|
||||
System.Diagnostics.Process P = System.Diagnostics.Process.GetProcessById(pID);
|
||||
foreach (System.Diagnostics.ProcessModule M in P.Modules)
|
||||
{
|
||||
if (M.ModuleName == "AdminInterface.dll")
|
||||
baseAddress = M.BaseAddress;
|
||||
if (M.ModuleName == "AdminInterface.dll" && M.BaseAddress != IntPtr.Zero)
|
||||
baseAddresses.Add(M.BaseAddress);
|
||||
}
|
||||
|
||||
if (baseAddress == IntPtr.Zero)
|
||||
{
|
||||
Program.getManager().mainLog.Write("Base address was not found!");
|
||||
return false;
|
||||
}
|
||||
|
||||
IntPtr lpLLAddress = GetProcAddress(GetModuleHandle("kernel32.dll"), "FreeLibrary");
|
||||
|
||||
IntPtr lpLLAddress = GetProcAddress(GetModuleHandle("kernel32.dll"), "FreeLibraryAndExitThread");
|
||||
|
||||
if (lpLLAddress == IntPtr.Zero)
|
||||
{
|
||||
Program.getManager().mainLog.Write("Could not obtain address of function address");
|
||||
Program.getManager().mainLog.Write("Could not obtain address of freelibary");
|
||||
return false;
|
||||
}
|
||||
|
||||
ClientId clientid = new ClientId();
|
||||
threadID = new IntPtr();
|
||||
|
||||
RtlCreateUserThread(ProcessHandle, IntPtr.Zero, false, 0, (uint)0, IntPtr.Zero, lpLLAddress, baseAddress, out threadID, out clientid);
|
||||
if (threadID == IntPtr.Zero)
|
||||
foreach (IntPtr baseAddress in baseAddresses)
|
||||
{
|
||||
Program.getManager().mainLog.Write("Could not create remote thread");
|
||||
return false;
|
||||
}
|
||||
RtlCreateUserThread(ProcessHandle, IntPtr.Zero, false, 0, (uint)0, IntPtr.Zero, lpLLAddress, baseAddress, out threadID, out clientid);
|
||||
if (threadID == IntPtr.Zero)
|
||||
{
|
||||
Program.getManager().mainLog.Write("Could not create remote thread");
|
||||
return false;
|
||||
}
|
||||
#if DEBUG
|
||||
Program.getManager().mainLog.Write("Thread ID is " + threadID);
|
||||
#endif
|
||||
uint responseCode = WaitForSingleObject(threadID, 3000);
|
||||
uint responseCode = WaitForSingleObject(threadID, 3000);
|
||||
|
||||
if (responseCode != 0x00000000L)
|
||||
{
|
||||
Program.getManager().mainLog.Write("Thread did not finish in a timely manner!");
|
||||
Program.getManager().mainLog.Write("Last error is: " + Marshal.GetLastWin32Error());
|
||||
return false;
|
||||
if (responseCode != 0x00000000L)
|
||||
{
|
||||
Program.getManager().mainLog.Write("Thread did not finish in a timely manner!", Log.Level.Debug);
|
||||
Program.getManager().mainLog.Write("Last error is: " + Marshal.GetLastWin32Error(), Log.Level.Debug);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
CloseHandle(ProcessHandle);
|
||||
|
Binary file not shown.
BIN
Admin/plugins/$SimpleStatsPlugin.dll
Normal file
BIN
Admin/plugins/$SimpleStatsPlugin.dll
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -24,6 +24,34 @@
|
||||
$("#history_dialog").load(this.href);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
$(function () {
|
||||
$('.pseudoLinkAlias').click(function (e) {
|
||||
e.preventDefault();
|
||||
$(this).next().toggle('fast');
|
||||
return true;
|
||||
});
|
||||
});
|
||||
|
||||
$(function () {
|
||||
$('a').click(function (e) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
var href = this.href;
|
||||
var parts = href.split('?');
|
||||
var url = parts[0];
|
||||
console.log(parts);
|
||||
var params = parts[1].split('?');
|
||||
var pp, inputs = '';
|
||||
for (var i = 0, n = params.length; i < n; i++) {
|
||||
pp = params[i].split('=');
|
||||
inputs += '<input type="hidden" name="' + pp[0] + '" value="' + pp[1] + '" />';
|
||||
}
|
||||
$("body").append('<form action="' + url + '" method="post" id="sneakySneaky">' + inputs + '</form>');
|
||||
$("#poster").submit();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -278,7 +278,6 @@
|
||||
border-radius: 0px 0px 11px 11px;
|
||||
}
|
||||
|
||||
|
||||
.players {
|
||||
float: left;
|
||||
width: 400px;
|
||||
@ -331,6 +330,11 @@
|
||||
font-size: 14pt;
|
||||
width: 505px;
|
||||
}
|
||||
|
||||
.playerAlias, .playerIPs
|
||||
{
|
||||
display: none;
|
||||
}
|
||||
|
||||
.chatFormat_submit, .chatFormat_submit:hover
|
||||
{
|
||||
|
Binary file not shown.
Binary file not shown.
@ -98,7 +98,12 @@ namespace SamplePlugin
|
||||
killerStats.KDR = killerStats.Kills / killerStats.Deaths;
|
||||
|
||||
playerStats.updateStats(Killer, killerStats);
|
||||
|
||||
killerStats.killStreak++;
|
||||
killerStats.deathStreak = 0;
|
||||
}
|
||||
|
||||
Killer.Tell(messageOnStreak(killerStats.killStreak, killerStats.deathStreak));
|
||||
}
|
||||
|
||||
if (E.Type == Event.GType.Death)
|
||||
@ -110,6 +115,11 @@ namespace SamplePlugin
|
||||
victimStats.KDR = victimStats.Kills / victimStats.Deaths;
|
||||
|
||||
playerStats.updateStats(Victim, victimStats);
|
||||
|
||||
victimStats.deathStreak++;
|
||||
victimStats.killStreak = 0;
|
||||
|
||||
Victim.Tell(messageOnStreak(victimStats.killStreak, victimStats.deathStreak));
|
||||
}
|
||||
}
|
||||
|
||||
@ -123,6 +133,32 @@ namespace SamplePlugin
|
||||
|
||||
}
|
||||
|
||||
private String messageOnStreak(int killStreak, int deathStreak)
|
||||
{
|
||||
String Message = "";
|
||||
switch (killStreak)
|
||||
{
|
||||
case 5:
|
||||
Message = "Great job! You're on a ^55 killstreak!";
|
||||
break;
|
||||
case 10:
|
||||
Message = "Amazing! ^510 ^7kills without dying!";
|
||||
break;
|
||||
}
|
||||
|
||||
switch (deathStreak)
|
||||
{
|
||||
case 5:
|
||||
Message = "Pick it up soldier, you've died 5 times in a row...";
|
||||
break;
|
||||
case 10:
|
||||
Message = "Seriously? ^510 ^7deaths without getting a kill?";
|
||||
break;
|
||||
}
|
||||
|
||||
return Message;
|
||||
}
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get { return "Basic Stats"; }
|
||||
@ -204,11 +240,15 @@ namespace SamplePlugin
|
||||
Deaths = D;
|
||||
KDR = DR;
|
||||
Skill = S;
|
||||
deathStreak = 0;
|
||||
killStreak = 0;
|
||||
}
|
||||
|
||||
public int Kills;
|
||||
public int Deaths;
|
||||
public double KDR;
|
||||
public double Skill;
|
||||
public int deathStreak;
|
||||
public int killStreak;
|
||||
}
|
||||
}
|
@ -47,7 +47,7 @@
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>copy /Y "$(TargetDir)$(TargetName).dll" "$(SolutionDir)Admin\plugins\$(TargetName).dll"</PostBuildEvent>
|
||||
<PostBuildEvent>copy /Y "$(TargetDir)$(TargetName).dll" "$(SolutionDir)Admin\plugins\$SimpleStatsPlugin.dll"</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.
|
||||
|
@ -239,7 +239,7 @@ namespace SharedLibrary
|
||||
/// <param name="Target">Player to send message to</param>
|
||||
public void Tell(String Message, Player Target)
|
||||
{
|
||||
if (Target.clientID > -1)
|
||||
if (Target.clientID > -1 && Message.Length > 0)
|
||||
executeCommand("tellraw " + Target.clientID + " " + Message + "^7");
|
||||
|
||||
if (Target.Level == Player.Permission.Console)
|
||||
|
@ -90,6 +90,11 @@ namespace SharedLibrary
|
||||
return Cleaned.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove all IW Engine color codes
|
||||
/// </summary>
|
||||
/// <param name="str">String containing color codes</param>
|
||||
/// <returns></returns>
|
||||
public static String stripColors(String str)
|
||||
{
|
||||
if (str == null)
|
||||
@ -97,6 +102,11 @@ namespace SharedLibrary
|
||||
return Regex.Replace(str, @"\^[0-9]", "");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the IW Engine color code corresponding to an admin level
|
||||
/// </summary>
|
||||
/// <param name="level">Specified player level</param>
|
||||
/// <returns></returns>
|
||||
public static String levelToColor(Player.Permission level)
|
||||
{
|
||||
switch (level)
|
||||
@ -114,6 +124,11 @@ namespace SharedLibrary
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// HTML formatted level color
|
||||
/// </summary>
|
||||
/// <param name="Level">Specified player level</param>
|
||||
/// <returns></returns>
|
||||
public static String levelHTMLFormatted(Player.Permission Level)
|
||||
{
|
||||
switch (Level)
|
||||
@ -186,6 +201,11 @@ namespace SharedLibrary
|
||||
return str;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the full gametype name
|
||||
/// </summary>
|
||||
/// <param name="input">Shorthand gametype reported from server</param>
|
||||
/// <returns></returns>
|
||||
public static String gametypeLocalized(String input)
|
||||
{
|
||||
switch (input)
|
||||
@ -293,6 +313,8 @@ namespace SharedLibrary
|
||||
return "fifth";
|
||||
case 100:
|
||||
return "One-Hundreth (amazing!)";
|
||||
case 500:
|
||||
return "^7You're really ^5dedicated ^7to this server! This is your ^5500th ^7time connecting!";
|
||||
default:
|
||||
return connection.ToString() + Prefix;
|
||||
}
|
||||
|
@ -97,6 +97,15 @@ namespace Webfront_Plugin
|
||||
|
||||
private String processReplacements(String Input, String Macro, int curPage, int ID, String Query, params Server[] Servers)
|
||||
{
|
||||
bool Authenticated = false;
|
||||
|
||||
if (Servers[0] != null && Manager.lastIP != null)
|
||||
{
|
||||
Player User = Servers[0].clientDB.getPlayer(Manager.lastIP.ToString());
|
||||
if (User != null && User.Level > Player.Permission.Flagged)
|
||||
Authenticated = true;
|
||||
}
|
||||
|
||||
if (Macro.Length < 5)
|
||||
return "";
|
||||
|
||||
@ -110,13 +119,13 @@ namespace Webfront_Plugin
|
||||
foreach (Server S in activeServers)
|
||||
{
|
||||
StringBuilder players = new StringBuilder();
|
||||
if (S.getClientNum() < 1)
|
||||
players.Append("<h2>No Players</h2>");
|
||||
else
|
||||
if (S.getClientNum() > 0)
|
||||
{
|
||||
int count = 0;
|
||||
double currentPlayers = S.statusPlayers.Count;
|
||||
|
||||
players.Append("<table cellpadding='0' cellspacing='0' class='players'>");
|
||||
|
||||
foreach (Player P in S.getPlayers())
|
||||
{
|
||||
if (P == null)
|
||||
@ -147,6 +156,7 @@ namespace Webfront_Plugin
|
||||
count++;
|
||||
|
||||
}
|
||||
players.Append("</table>");
|
||||
}
|
||||
buffer.AppendFormat(@"<table cellpadding=0 cellspacing=0 class=server>
|
||||
<tr>
|
||||
@ -159,11 +169,12 @@ namespace Webfront_Plugin
|
||||
<th><a class='history' href='/graph?server={4}'>History</a></th>
|
||||
</tr>
|
||||
</table>
|
||||
<table cellpadding='0' cellspacing='0' class='players'>
|
||||
{5}
|
||||
</table>",
|
||||
{5}",
|
||||
|
||||
S.getName(), S.getMap(), S.getClientNum() + "/" + S.getMaxClients(), SharedLibrary.Utilities.gametypeLocalized(S.getGametype()), S.pID(), players.ToString());
|
||||
buffer.AppendFormat("<div class='chatHistory' id='chatHistory_{0}'></div><script type='text/javascript'>$( document ).ready(function() {{ setInterval({1}loadChatMessages({0}, '#chatHistory_{0}'){1}, 2500); }});</script><div class='null' style='clear:both;'></div>", S.pID(), '\"');
|
||||
|
||||
if (S.getClientNum() > 0)
|
||||
buffer.AppendFormat("<div class='chatHistory' id='chatHistory_{0}'></div><script type='text/javascript'>$( document ).ready(function() {{ setInterval({1}loadChatMessages({0}, '#chatHistory_{0}'){1}, 2500); }});</script><div class='null' style='clear:both;'></div>", S.pID(), '\"');
|
||||
//if (S.getClientNum() > 0)
|
||||
// buffer.AppendFormat("<form class='chatOutFormat' action={1}javascript:chatRequest({0}, 'chatEntry_{0}'){1}><input class='chatFormat_text' type='text' placeholder='Enter a message...' id='chatEntry_{0}'/><input class='chatFormat_submit' type='submit'/></form>", S.pID(), '\"');
|
||||
buffer.Append("<hr/>");
|
||||
@ -230,30 +241,35 @@ namespace Webfront_Plugin
|
||||
|
||||
List<Aliases> allAlliases = S.getAliases(Player);
|
||||
List<String> nameAlias = new List<String>();
|
||||
List<String> IPAlias = new List<String>();
|
||||
|
||||
foreach (Aliases A in allAlliases)
|
||||
{
|
||||
foreach (String Name in A.Names.Distinct())
|
||||
nameAlias.Add(Name);
|
||||
}
|
||||
|
||||
if (Authenticated)
|
||||
{
|
||||
foreach (String IP in A.IPS.Distinct())
|
||||
IPAlias.Add(IP);
|
||||
}
|
||||
}
|
||||
str.Append("<a href='#' class='pseudoLinkAlias'>Show Aliases</a>");
|
||||
str.Append("<div class='playerAlias'>");
|
||||
foreach (String Name in nameAlias.Distinct())
|
||||
str.AppendFormat("<span>{0}</span><br/>", Utilities.stripColors(Name));
|
||||
str.Append("</div>");
|
||||
|
||||
|
||||
StringBuilder IPs = new StringBuilder();
|
||||
|
||||
if (false)
|
||||
|
||||
if (Authenticated)
|
||||
{
|
||||
/*foreach (Player a in aliases)
|
||||
{
|
||||
foreach (String ip in a.Alias.IPS)
|
||||
{
|
||||
if (!IPs.ToString().Contains(ip))
|
||||
IPs.AppendFormat("<span>{0}</span><br/>", ip);
|
||||
}
|
||||
}*/
|
||||
|
||||
IPs.Append("<a href='#'><span class='pseudoLinkIP'><i>Show IPs</i></span></a>");
|
||||
IPs.Append("<div class='playerIPs'>");
|
||||
foreach (String IP in IPAlias)
|
||||
IPs.AppendFormat("<span>{0}</span><br/>", IP);
|
||||
IPs.Append("</div>");
|
||||
}
|
||||
else
|
||||
IPs.Append("Hidden");
|
||||
@ -268,7 +284,7 @@ namespace Webfront_Plugin
|
||||
String Screenshot = String.Empty;
|
||||
|
||||
//if (logged)
|
||||
Screenshot = String.Format("<a href='http://server.nbsclan.org/screen.php?id={0}&name={1}'><div style='background-image:url(http://server.nbsclan.org/shutter.png); width: 20px; height: 20px;float: right; position:relative; right: 21%; background-size: contain;'></div></a>", forumID, Player.Name);
|
||||
Screenshot = String.Format("<a href='http://server.nbsclan.org/screen.php?id={0}&name={1}' target='_blank'><div style='background-image:url(http://server.nbsclan.org/shutter.png); width: 20px; height: 20px;float: right; position:relative; right: 21%; background-size: contain;'></div></a>", forumID, Player.Name);
|
||||
|
||||
buffer.AppendFormat("<td><a style='float: left;' href='{9}'>{0}</a>{10}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td>{5}</td><td>{6} ago</td><td><a href='https://repziw4.de/memberlist.php?mode=viewprofile&u={7}'>{8}</a></td>", Player.Name, str, IPs, 0, SharedLibrary.Utilities.levelHTMLFormatted(Player.Level), Player.Connections, Player.getLastConnection(), forumID, Player.Name, "/player?id=" + Player.databaseID, Screenshot);
|
||||
buffer.Append("</tr>");
|
||||
|
@ -6,30 +6,25 @@ namespace Webfront_Plugin
|
||||
{
|
||||
public class Webfront : Plugin
|
||||
{
|
||||
private static Manager webManager;
|
||||
private static Thread webManagerThread;
|
||||
|
||||
public override void onEvent(Event E)
|
||||
{
|
||||
if (webManager != null)
|
||||
if (E.Type == Event.GType.Start)
|
||||
{
|
||||
if (E.Type == Event.GType.Start)
|
||||
{
|
||||
Manager.webFront.addServer(E.Owner);
|
||||
E.Owner.Log.Write("Webfront now has access to server on port " + E.Owner.getPort(), Log.Level.Production);
|
||||
}
|
||||
if (E.Type == Event.GType.Stop)
|
||||
{
|
||||
Manager.webFront.removeServer(E.Owner);
|
||||
E.Owner.Log.Write("Webfront has lost access to server on port " + E.Owner.getPort(), Log.Level.Production);
|
||||
}
|
||||
Manager.webFront.addServer(E.Owner);
|
||||
E.Owner.Log.Write("Webfront now has access to server on port " + E.Owner.getPort(), Log.Level.Production);
|
||||
}
|
||||
if (E.Type == Event.GType.Stop)
|
||||
{
|
||||
Manager.webFront.removeServer(E.Owner);
|
||||
E.Owner.Log.Write("Webfront has lost access to server on port " + E.Owner.getPort(), Log.Level.Production);
|
||||
}
|
||||
}
|
||||
|
||||
public override void onLoad()
|
||||
{
|
||||
webManager = new Manager();
|
||||
webManagerThread = new Thread(new ThreadStart(webManager.Init));
|
||||
webManagerThread = new Thread(new ThreadStart(Manager.Init));
|
||||
webManagerThread.Name = "Webfront";
|
||||
|
||||
webManagerThread.Start();
|
||||
@ -37,7 +32,7 @@ namespace Webfront_Plugin
|
||||
|
||||
public override void onUnload()
|
||||
{
|
||||
webManager.webScheduler.Stop();
|
||||
Manager.webScheduler.Stop();
|
||||
webManagerThread.Join();
|
||||
}
|
||||
|
||||
|
@ -8,24 +8,42 @@ using System.Net;
|
||||
|
||||
namespace Webfront_Plugin
|
||||
{
|
||||
class Manager
|
||||
static class Manager
|
||||
{
|
||||
public IScheduler webScheduler { get; private set; }
|
||||
public static IScheduler webScheduler { get; private set; }
|
||||
public static Framework webFront { get; private set; }
|
||||
public static IPAddress lastIP;
|
||||
|
||||
public Manager()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Init()
|
||||
public static void Init()
|
||||
{
|
||||
webScheduler = KayakScheduler.Factory.Create(new SchedulerDelegate());
|
||||
var server = KayakServer.Factory.CreateHttp(new RequestDelegate(), webScheduler);
|
||||
var server = KayakServer.Factory.Create(new ServerDelegate(), webScheduler);
|
||||
|
||||
webFront = new Framework();
|
||||
|
||||
using (server.Listen(new IPEndPoint(IPAddress.Any, 1624)))
|
||||
webScheduler.Start();
|
||||
}
|
||||
}
|
||||
|
||||
class HttpServerDelegate : IServerDelegate
|
||||
{
|
||||
IHttpRequestDelegate requestDelegate;
|
||||
|
||||
public HttpServerDelegate(IHttpRequestDelegate requestDelegate)
|
||||
{
|
||||
this.requestDelegate = requestDelegate;
|
||||
|
||||
}
|
||||
|
||||
public ISocketDelegate OnConnection(IServer server, ISocket socket)
|
||||
{
|
||||
// Kayak.Http.IHttpServerFactory
|
||||
}
|
||||
|
||||
public void OnClose(IServer server)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,7 +56,7 @@ namespace Webfront_Plugin
|
||||
|
||||
public void OnStop(IScheduler scheduler)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user