370 lines
12 KiB
JavaScript
370 lines
12 KiB
JavaScript
function showKbanInfo(button) {
|
|
let id = $(button).attr('id-data');
|
|
let diva = '#diva-' + id;
|
|
$(diva + '-tr').slideToggle();
|
|
if ($(diva).attr('is_slided') == 0) {
|
|
$(diva).attr('is_slided', 1);
|
|
$(diva).slideDown();
|
|
$(diva).css('display', 'flex');
|
|
} else {
|
|
$(diva).attr('is_slided', 0);
|
|
$(diva).slideUp();
|
|
}
|
|
}
|
|
|
|
function getCsrfToken() {
|
|
if (window.CSRF_TOKEN) {
|
|
return window.CSRF_TOKEN;
|
|
}
|
|
|
|
const meta = document.querySelector('meta[name="csrf-token"]');
|
|
return meta ? meta.getAttribute('content') : '';
|
|
}
|
|
|
|
function GoTop() {
|
|
if (document.documentElement.scrollTop > 450 || document.body.scrollTop > 450) {
|
|
document.body.scrollTop = 200;
|
|
document.documentElement.scrollTop = 200;
|
|
}
|
|
}
|
|
|
|
function ConfirmUnban(id, name, steamid) {
|
|
let reason = prompt('Please type the reason why you would Kunban ' + name + '[' + steamid + ']');
|
|
let confirmMessage = 'Are you sure you want to Kunban ' + name + '[' + steamid + ']';
|
|
let confirmHandler = confirm(confirmMessage);
|
|
if (confirmHandler == true) {
|
|
UnBanByID(encodeURIComponent(id), encodeURIComponent(reason));
|
|
}
|
|
}
|
|
|
|
function UnBanByID(id, reason) {
|
|
var xmlResponse1 = new XMLHttpRequest();
|
|
xmlResponse1.onreadystatechange = function() {
|
|
if (this.readyState == 4 && this.status == 200) {
|
|
$('#diva-' + id).html(this.responseText);
|
|
|
|
let trDiva = document.getElementById('diva-tr-' + id);
|
|
trDiva.className = "row-expired";
|
|
let oldHtml = $('#length-' + id).html();
|
|
let newHtml = (oldHtml + ' (Removed)');
|
|
$('#length-' + id).html(newHtml);
|
|
}
|
|
};
|
|
|
|
xmlResponse1.open("POST", "functions_url.php", true);
|
|
xmlResponse1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
|
xmlResponse1.send(
|
|
"oldid=" + encodeURIComponent(id) +
|
|
"&reason=" + encodeURIComponent(reason) +
|
|
"&csrf_token=" + encodeURIComponent(getCsrfToken())
|
|
);
|
|
|
|
var xmlResponse2 = new XMLHttpRequest();
|
|
xmlResponse2.onreadystatechange = function() {
|
|
if (this.readyState == 4 && this.status == 200) {
|
|
// Process xmlResponse2.responseText here
|
|
}
|
|
};
|
|
|
|
xmlResponse2.open("GET", "functions_url.php?id=" + encodeURIComponent(id), true);
|
|
xmlResponse2.send();
|
|
}
|
|
|
|
function ViewPlayerHistory(steamid, method) {
|
|
let url = "index.php?all=true&s=" + encodeURIComponent(steamid) + "&m=" + encodeURIComponent(method);
|
|
window.location.replace(url);
|
|
}
|
|
|
|
function RebanFromID(id) {
|
|
let url = "manage.php?reban&oldid=" + encodeURIComponent(id);
|
|
window.location.replace(url);
|
|
}
|
|
|
|
function EditFromID(id) {
|
|
let url = "manage.php?edit&oldid=" + encodeURIComponent(id);
|
|
window.location.replace(url);
|
|
}
|
|
|
|
function addNewKban(playerName, playerSteamID, length, reason) {
|
|
var xmlResponse = new XMLHttpRequest();
|
|
xmlResponse.onreadystatechange = function() {
|
|
if (this.readyState == 4 && this.status == 200) {
|
|
$('.error').html(xmlResponse.responseText);
|
|
}
|
|
};
|
|
|
|
xmlResponse.open("POST", "functions_url.php", true);
|
|
xmlResponse.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
|
xmlResponse.send(
|
|
"add=1" +
|
|
"&playerName=" + encodeURIComponent(playerName) +
|
|
"&playerSteamID=" + encodeURIComponent(playerSteamID) +
|
|
"&length=" + encodeURIComponent(length) +
|
|
"&reason=" + encodeURIComponent(reason) +
|
|
"&csrf_token=" + encodeURIComponent(getCsrfToken())
|
|
);
|
|
}
|
|
|
|
function EditKban(id, playerName, playerSteamID, length, reason) {
|
|
var xmlResponse1 = new XMLHttpRequest();
|
|
xmlResponse1.onreadystatechange = function() {
|
|
if (this.readyState == 4) {
|
|
if (this.status == 200) {
|
|
$('.error').html(xmlResponse1.responseText);
|
|
} else {
|
|
$('.error').html("<p>Request failed (HTTP " + this.status + "). " + xmlResponse1.responseText + "</p>");
|
|
}
|
|
}
|
|
};
|
|
|
|
xmlResponse1.open("POST", "functions_url.php", true);
|
|
xmlResponse1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
|
xmlResponse1.send(
|
|
"edit=1" +
|
|
"&id=" + encodeURIComponent(id) +
|
|
"&playerName=" + encodeURIComponent(playerName) +
|
|
"&playerSteamID=" + encodeURIComponent(playerSteamID) +
|
|
"&length=" + encodeURIComponent(length) +
|
|
"&reason=" + encodeURIComponent(reason) +
|
|
"&csrf_token=" + encodeURIComponent(getCsrfToken())
|
|
);
|
|
}
|
|
|
|
function RemoveKbanFromDBCheck(id) {
|
|
let confirmMessage = "Are you sure you want to delete this kban from DB?";
|
|
let confirmHandler = confirm(confirmMessage);
|
|
if (confirmHandler == true) {
|
|
RemoveKbanFromDB(id);
|
|
}
|
|
}
|
|
|
|
function RemoveKbanFromDB(id) {
|
|
var xmlResponse1 = new XMLHttpRequest();
|
|
xmlResponse1.onreadystatechange = function() {
|
|
if (this.readyState !== 4) {
|
|
return;
|
|
}
|
|
|
|
if (this.status !== 200) {
|
|
alert('Delete request failed (HTTP ' + this.status + ').');
|
|
return;
|
|
}
|
|
|
|
const response = (xmlResponse1.responseText || '').trim();
|
|
if (!response) {
|
|
alert('Delete request returned an empty response.');
|
|
return;
|
|
}
|
|
|
|
// Keep backwards compatibility with PHP handlers returning <script>...</script>.
|
|
const scriptMatch = response.match(/<script[^>]*>([\s\S]*?)<\/script>/i);
|
|
if (scriptMatch && scriptMatch[1]) {
|
|
$.globalEval(scriptMatch[1]);
|
|
} else {
|
|
$('.hide').html(response);
|
|
}
|
|
};
|
|
|
|
xmlResponse1.open("POST", "functions_url.php", true);
|
|
xmlResponse1.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
|
xmlResponse1.send(
|
|
"delete=1" +
|
|
"&deleteid=" + encodeURIComponent(id) +
|
|
"&csrf_token=" + encodeURIComponent(getCsrfToken())
|
|
);
|
|
}
|
|
|
|
function setActive(num) {
|
|
/* 0 = All Kbans, 1 = Active Kbans, 2 = Expired Kbans, 3 = Add Kban, 4 = Web Logs, 5 = Server Logs */
|
|
if (num == 0) {
|
|
const bar = document.getElementById("allKbans");
|
|
bar.className = "active";
|
|
} else if (num == 1) {
|
|
const bar = document.getElementById("activeKbans");
|
|
bar.className = "active";
|
|
} else if (num == 2) {
|
|
const bar = document.getElementById("expiredKbans");
|
|
bar.className = "active";
|
|
} else if (num == 4) {
|
|
const bar = document.getElementById("weblogs");
|
|
bar.className = "active";
|
|
} else if (num == 5) {
|
|
const bar = document.getElementById("srvlogs");
|
|
bar.className = "active";
|
|
} else {
|
|
const bar = document.getElementById("addkban");
|
|
bar.className = "active";
|
|
}
|
|
}
|
|
|
|
function Login() {
|
|
window.location.replace('login-init.php');
|
|
}
|
|
|
|
$(function() {
|
|
$('.search-modal-btn-open').on('click', function(evt) {
|
|
if ($(this).attr('id') == "main-search") {
|
|
setModalSearch("all");
|
|
} else {
|
|
let type = $(this).attr('data-page');
|
|
setModalSearch(type);
|
|
}
|
|
|
|
$('.search-modal-body').toggle();
|
|
});
|
|
|
|
$('.search-modal-btn-close').on('click', function() {
|
|
$('.search-modal-body').toggle();
|
|
});
|
|
});
|
|
|
|
window.addEventListener('click', function(e) {
|
|
if (e.target.className == "search-modal-body") {
|
|
$('.search-modal-body').toggle();
|
|
}
|
|
});
|
|
|
|
function setModalSearch(type) {
|
|
$('#hideInput').attr('name', type);
|
|
}
|
|
|
|
function showKbanWindowInfo(type, playerName = "", playerSteamID = "", reason = "", length = "", id = 0) {
|
|
/* type values: 0 = Add Kban, 1 = Edit Kban, 2 = Unban Kban, 3 = Delete Kban */
|
|
const titles = [
|
|
"Kban Added",
|
|
"Kban Edited",
|
|
"Kban Unbanned",
|
|
"Kban Deleted"
|
|
];
|
|
|
|
const title = titles[type];
|
|
$('#action-header-text').html(title + " <i class='fa-solid fa-check' style='color: var(--button-success);'></i>");
|
|
|
|
let html = "";
|
|
if (playerName[0]) {
|
|
html += "<li>";
|
|
html += "<span>";
|
|
html += "<i class='fas fa-user'></i> Player";
|
|
html += "</span>";
|
|
html += "<span>";
|
|
html += playerName;
|
|
html += "</span>";
|
|
html += "</li>";
|
|
}
|
|
|
|
if (playerSteamID[0]) {
|
|
html += "<li>";
|
|
html += "<span>";
|
|
html += "<i class='fab fa-steam-symbol'></i> Steam ID";
|
|
html += "</span>";
|
|
html += "<span>";
|
|
html += playerSteamID;
|
|
html += "</span>";
|
|
html += "</li>";
|
|
}
|
|
|
|
if (reason[0]) {
|
|
html += "<li>";
|
|
html += "<span>";
|
|
html += "<i class='fas fa-question'></i> Reason";
|
|
html += "</span>";
|
|
html += "<span>";
|
|
html += reason;
|
|
html += "</span>";
|
|
html += "</li>";
|
|
}
|
|
|
|
if (length[0]) {
|
|
html += "<li>";
|
|
html += "<span>";
|
|
html += "<i class='fas fa-hourglass-half'></i> Duration";
|
|
html += "</span>";
|
|
html += "<span>";
|
|
html += length;
|
|
html += "</span>";
|
|
html += "</li>";
|
|
}
|
|
|
|
if (type == 3) {
|
|
let diva1 = '#diva-' + encodeURIComponent(id);
|
|
$(diva1 + '-tr').hide();
|
|
|
|
let diva2 = '#diva-tr-' + encodeURIComponent(id);
|
|
$(diva2).hide();
|
|
|
|
let totalResults = $('#totalText').attr('results');
|
|
let totalHtml = $('#totalText').html();
|
|
|
|
let totalResultsAfter = totalResults - 1;
|
|
let totalResultsString = totalResults.toString();
|
|
let totalResultsAfterString = totalResultsAfter.toString();
|
|
|
|
let newTotalHtml = totalHtml.replace(totalResultsString, totalResultsAfterString);
|
|
$('#totalText').attr('results', totalResultsAfter);
|
|
$('#totalText').html(newTotalHtml);
|
|
|
|
let startResults = $('#displaying-text').attr('results');
|
|
let endResults = $('#displaying-text').attr('totalresults');
|
|
let displayHtml = $('#displaying-text').html();
|
|
|
|
let startResultsString = startResults.toString();
|
|
let startResultsAfter = 0;
|
|
|
|
if (startResults != 0) {
|
|
startResultsAfter = startResults - 1;
|
|
}
|
|
|
|
let startResultsAfterString = startResultsAfter.toString();
|
|
|
|
let endResultsString = endResults.toString();
|
|
let endResultsAfter = endResults - 1;
|
|
let endResultsAfterString = endResultsAfter.toString();
|
|
|
|
$('#displaying-text').attr('results', startResultsAfter);
|
|
$('#displaying-text').attr('totalresults', endResultsAfter);
|
|
|
|
let newDisplayHtml = "";
|
|
if (startResults == endResults) {
|
|
let first = displayHtml.replace('-' + ' ' + totalResultsString, '-' + ' ' + totalResultsAfterString);
|
|
newDisplayHtml = first.replace(startResultsString, startResultsAfterString);
|
|
} else {
|
|
let first = displayHtml.replace(startResultsString, startResultsAfterString);
|
|
let second = first.replace('-' + ' ' + totalResultsString, '-' + ' ' + totalResultsAfterString);
|
|
newDisplayHtml = second.replace(endResultsString, endResultsAfterString);
|
|
}
|
|
|
|
$('#displaying-text').html(newDisplayHtml);
|
|
|
|
let count = $('#' + encodeURIComponent(id) + '-count').attr('count');
|
|
let newCountHtml = count ? (count - 1) : 0;
|
|
|
|
var allCounts = document.getElementsByClassName('count');
|
|
for (var i = 0; i < allCounts.length; i++) {
|
|
let steamID = $('#' + allCounts[i].id).attr('steamid');
|
|
if (steamID == playerSteamID) {
|
|
$('#' + allCounts[i].id).attr('count', newCountHtml);
|
|
let Html = $('#' + allCounts[i].id).html();
|
|
if (count) {
|
|
let newHtml = Html.replace(count.toString(), newCountHtml.toString());
|
|
$('#' + allCounts[i].id).html(newHtml);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
$('.kban-action-window .info .kban_details').html(html);
|
|
|
|
$('.kban-action-window').css('display', 'block');
|
|
|
|
let sec = 3;
|
|
setTimeout(CloseWindow, (sec * 1000));
|
|
}
|
|
|
|
function CloseWindow() {
|
|
$('.kban-action-window').css('display', 'none');
|
|
}
|
|
|
|
function GoHome() {
|
|
window.location.href = 'index.php?all';
|
|
}
|