fixed aliases

fixed forum decoding of thread content
fixed escaping html "special" characters in player names on webfront
fixed findall not always informing if no matches found.
This commit is contained in:
RaidMax 2017-11-19 00:44:11 -06:00
parent 9a85b9c4c2
commit 2aa3aa5baf
9 changed files with 80 additions and 59 deletions

View File

@ -15,6 +15,8 @@ namespace IW4MAdmin
static void Main(string[] args)
{
System.Diagnostics.Process.GetCurrentProcess().PriorityClass = System.Diagnostics.ProcessPriorityClass.BelowNormal;
Version = 1.6;
handler = new ConsoleEventDelegate(OnProcessExit);
SetConsoleCtrlHandler(handler, true);

View File

@ -285,6 +285,7 @@ namespace IW4MAdmin
GetAliases(allAliases, currentIdentityAliases);
if (Origin.Alias != null)
allAliases.Add(Origin.Alias);
allAliases.Add(currentIdentityAliases);
return allAliases;
}

View File

@ -758,8 +758,9 @@ namespace IW4MAdmin
bool authed = ApplicationManager.GetInstance().GetClientDatabase().GetAdmins().FindAll(x => x.IP == querySet["IP"] && x.Level > Player.Permission.Trusted).Count > 0
|| querySet["IP"] == "127.0.0.1";
bool recent = false;
bool individual = querySet["id"] != null;
if (querySet["id"] != null)
if (individual)
{
matchedPlayers.Add(ApplicationManager.GetInstance().GetClientDatabase().GetPlayer(Convert.ToInt32(querySet["id"])));
}
@ -801,18 +802,24 @@ namespace IW4MAdmin
playernpID = pp.NetworkID,
forumID = -1,
authed = authed,
showV2Features = false
showV2Features = false,
playerAliases = new List<string>(),
playerIPs = new List<string>()
};
if (!recent)
if (!recent && individual)
{
foreach (var a in ApplicationManager.GetInstance().GetAliases(pp))
{
eachPlayer.playerAliases = a.Names;
eachPlayer.playerIPs = a.IPS;
eachPlayer.playerAliases.AddRange(a.Names);
eachPlayer.playerIPs.AddRange(a.IPS);
}
}
eachPlayer.playerAliases = eachPlayer.playerAliases.Distinct().ToList();
eachPlayer.playerIPs = eachPlayer.playerIPs.Distinct().ToList();
eachPlayer.playerConnections = pp.Connections;
eachPlayer.lastSeen = Utilities.GetTimePassed(pp.LastConnection);
pInfo.Add(eachPlayer);

Binary file not shown.

View File

@ -8,6 +8,7 @@ CHANGELOG:
-prune command demotes inactive admins (defaults to 30 days if no days are specified)
-confirmation message sent after kick
-paginated players page
-fixed aliases
Version 1.5
CHANGELOG:

View File

@ -1,34 +1,29 @@
<script>
var curFrom = 0;
var curFrom = 0;
function getNextPage()
{
curFrom += 15;
return curFrom;
}
function getNextPage() {
curFrom += 15;
return curFrom;
}
function getPrevPage()
{
if ((curFrom - 15) >= 0)
{
curFrom -= 15;
return (curFrom );
}
else
{
curFrom = 0;
return 0;
}
}
function getPrevPage() {
if ((curFrom - 15) >= 0) {
curFrom -= 15;
return (curFrom);
}
else {
curFrom = 0;
return 0;
}
}
function getPenalties(from)
{
$("#penaltyList").html("");
$(".loader").fadeIn();
$.getJSON("/_penalties?from=" + from, function(result) {
$.each(result, function(i, penalty) {
$("#penaltyList").append(
"<div class=\"playerPenalty table alternate_" + i % 2 + "\"> \
function getPenalties(from) {
$("#penaltyList").html("");
$(".loader").fadeIn();
$.getJSON("/_penalties?from=" + from, function (result) {
$.each(result, function (i, penalty) {
$("#penaltyList").append(
"<div class=\"playerPenalty table alternate_" + i % 2 + "\"> \
<div class=\"penaltyName tableCell\"><a href=\"/players?id="+ penalty['playerID'] + "\">" + penalty['playerName'] + "</a></div> \
<div class=\"penaltyType tableCell\">"+ getColorForLevel(penalty['penaltyType'], penalty['penaltyType']) + "</div> \
<div class=\"penaltyReason tableCell\">"+ penalty['penaltyReason'] + "</div> \
@ -36,28 +31,28 @@ function getPenalties(from)
<div class=\"penaltyTime tableCell\">"+ penalty['penaltyTime'] + "</div> \
<div class=\" penaltyRemaining tableCell\">" + penalty['Expires'] + "</div> \
</div>"
)
});
)
});
}).done(function (data) { $(".loader").fadeOut(); });
}
$( document ).ready(function() {
getPenalties(0);
});
}).done(function (data) { $(".loader").fadeOut(); });
}
$(document).ready(function () {
getPenalties(0);
});
</script>
<div class="penaltyHeader table">
<div class="penaltyName tableCell">Name</div>
<div class="penaltyType tableCell">Type</div>
<div class="penaltyReason tableCell">Reason</div>
<div class="penaltyOrigin tableCell">Admin</div>
<div class="penaltyTime tableCell">Time</div>
<div class="penaltyRemaining tableCell">Remaining</div>
<div class="penaltyName tableCell">Name</div>
<div class="penaltyType tableCell">Type</div>
<div class="penaltyReason tableCell">Reason</div>
<div class="penaltyOrigin tableCell">Admin</div>
<div class="penaltyTime tableCell">Time</div>
<div class="penaltyRemaining tableCell">Remaining</div>
</div>
<div id="penaltyList">
</div>
<hr />
<div id="paginationButtons" class="table">
<div id="paginationButtons" class="table">
<div id="previousPage" class="tableCell"><a href=# onclick="getPenalties(getPrevPage())"><<</a></div>
<div id="nextPage" class="tableCell"><a href=# onclick="getPenalties(getNextPage())">>></a></div>
</div>
</div>

View File

@ -1,4 +1,14 @@
<script>
function escapeHtml(unsafe) {
return unsafe
.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&#039;");
}
var curFrom = 0;
function getNextPage() {
@ -9,18 +19,22 @@
function getPrevPage() {
if ((curFrom - 15) >= 0) {
curFrom -= 15;
return (curFrom - 15);
return (curFrom);
}
else
else {
curFrom = 0;
return 0;
}
}
function formatHidden(data, authed) {
var p = "<div class=\"hiddenWrapper\"><span>Expand</span><div class=\"hiddenElements\">";
if (authed) {
if (data == undefined || data.length == 0)
p += "Not Loaded"
$.each(data, function (i, dat) {
p += "<span>" + dat + "</span><br/>"
p += "<span>" + escapeHtml(dat) + "</span><br/>"
})
}
@ -36,7 +50,7 @@
var p = "";
p +=
"<div class=\"playerInfo table alternate_" + i % 2 + "\"> \
<div class=\"tableCell\"><a href=\"/players?id=" + player['playerID'] + "\">" + player['playerName'] + "</a></div> \
<div class=\"tableCell\"><a href=\"/players?id=" + player['playerID'] + "\">" + escapeHtml(player['playerName']) + "</a></div> \
<div class=\"tableCell\">" + formatHidden(player['playerAliases'], player.authed) + "</div> \
<div class=\"tableCell\">" + formatHidden(player['playerIPs'], player.authed) + "</div> \
<div class=\"tableCell\">" + getColorForLevel(player['playerLevel'], player['playerLevel']) + "</div> \
@ -73,7 +87,8 @@
$.each(result, function (i, player) {
printPlayer(player, i);
});
}).done(function (data) { $(".loader").fadeOut(); });
}).done(function (data) { $(".loader").fadeOut(); })
.error(function (data) { $(".loader").fadeOut(); })
}
$(document).ready(function () {

View File

@ -577,7 +577,7 @@ namespace SharedLibrary.Commands
var db_aliases = E.Owner.Manager.GetAliasesDatabase().FindPlayerAliases(E.Data);
if (db_aliases == null)
if (db_aliases == null || db_aliases.Count() == 0)
{
await E.Origin.Tell("No players found");
return;
@ -620,9 +620,9 @@ namespace SharedLibrary.Commands
if (E.Owner.Rules.Count < 1)
{
if (E.Message.IsBroadcastCommand())
await E.Owner.Broadcast("The server owner has not set any rules.");
await E.Owner.Broadcast("The server owner has not set any rules");
else
await E.Origin.Tell("The server owner has not set any rules.");
await E.Origin.Tell("The server owner has not set any rules");
}
else
@ -753,7 +753,7 @@ namespace SharedLibrary.Commands
if (E.Target == E.Origin)
{
await E.Origin.Tell("You cannot report yourself.");
await E.Origin.Tell("You cannot report yourself");
return;
}
@ -796,7 +796,7 @@ namespace SharedLibrary.Commands
if (E.Owner.Reports.Count < 1)
{
await E.Origin.Tell("No players reported yet.");
await E.Origin.Tell("No players reported yet");
return;
}
@ -848,7 +848,7 @@ namespace SharedLibrary.Commands
if (BannedPenalty == null)
{
await E.Origin.Tell("No active ban was found for that player.");
await E.Origin.Tell("No active ban was found for that player");
return;
}

View File

@ -665,7 +665,7 @@ namespace SharedLibrary
{
CommandText = "SELECT * FROM ALIASES WHERE IPS LIKE @IP"
};
cmd.Parameters.AddWithValue("@IP", IP);
cmd.Parameters.AddWithValue("@IP", $"%{IP}%");
var Result = GetDataTable(cmd);