mirror of
https://gitlab.com/ruany/litebans-php.git
synced 2025-07-09 15:27:32 +00:00
Add ban check form.
This commit is contained in:
parent
ec16759705
commit
88fba6ed62
39
bans.php
39
bans.php
@ -10,6 +10,40 @@
|
|||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<br/>
|
||||||
|
<!-- Ban check form -->
|
||||||
|
<form id="form" class="form-inline">
|
||||||
|
<div class="form-group">
|
||||||
|
<input type="text" class="form-control" id="user" placeholder="Player">
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-default">Check</button>
|
||||||
|
</form>
|
||||||
|
<script type="text/javascript">
|
||||||
|
function runCheck() {
|
||||||
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: 'check.php',
|
||||||
|
data: {name: document.getElementById('user').value, table: 'bans'}
|
||||||
|
}).done(function (msg) {
|
||||||
|
document.getElementById('output').innerHTML = msg;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// prevent page from being reloaded on submit
|
||||||
|
// https://stackoverflow.com/questions/5384712/capture-a-form-submit-in-javascript
|
||||||
|
function processForm(e) {
|
||||||
|
if (e.preventDefault) e.preventDefault();
|
||||||
|
runCheck();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var form = document.getElementById('form');
|
||||||
|
if (form.attachEvent) {
|
||||||
|
form.attachEvent("submit", processForm);
|
||||||
|
} else {
|
||||||
|
form.addEventListener("submit", processForm);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<div id="output"></div>
|
||||||
|
<!-- End ban check form -->
|
||||||
<div class="row" style="margin-bottom:60px;">
|
<div class="row" style="margin-bottom:60px;">
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<table class="table table-hover table-bordered table-condensed">
|
<table class="table table-hover table-bordered table-condensed">
|
||||||
@ -37,9 +71,8 @@
|
|||||||
global $table_bans, $conn;
|
global $table_bans, $conn;
|
||||||
$result = run_query($table_bans);
|
$result = run_query($table_bans);
|
||||||
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
|
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
|
||||||
date_default_timezone_set("UTC");
|
$timeResult = millis_to_date($row['time']);
|
||||||
$timeResult = date('F j, Y, g:i a', $row['time'] / 1000);
|
$expiresResult = millis_to_date($row['until']);
|
||||||
$expiresResult = date('F j, Y, g:i a', $row['until'] / 1000);
|
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><?php echo get_avatar($row['name']); ?></td>
|
<td><?php echo get_avatar($row['name']); ?></td>
|
||||||
|
33
check.php
Normal file
33
check.php
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
if (isset($_POST['name'], $_POST['table'])) {
|
||||||
|
require 'includes/page.php';
|
||||||
|
$name = $_POST['name']; // user input
|
||||||
|
global $table_bans, $table_history, $conn;
|
||||||
|
$stmt = $conn->prepare("SELECT uuid FROM " . $table_history . " WHERE name=? ORDER BY date LIMIT 1");
|
||||||
|
if ($stmt->execute(array($name))) {
|
||||||
|
if ($row = $stmt->fetch()) {
|
||||||
|
$uuid = $row['uuid'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isset($uuid)) {
|
||||||
|
$stmt = $conn->prepare("SELECT * FROM " . $table_bans . " WHERE (uuid=? AND active=1) LIMIT 1");
|
||||||
|
if ($stmt->execute(array($uuid))) {
|
||||||
|
if ($row = $stmt->fetch()) {
|
||||||
|
$banner = get_banner_name($row['banned_by_name']);
|
||||||
|
$reason = $row['reason'];
|
||||||
|
$time = millis_to_date($row['time']);
|
||||||
|
$until = millis_to_date($row['until']);
|
||||||
|
echo($name . ' is banned! <br>');
|
||||||
|
echo('Banned by ' . $banner . '<br>');
|
||||||
|
echo('Reason: ' . $reason . '<br>');
|
||||||
|
echo('Banned on: ' . $time . '<br>');
|
||||||
|
echo('Banned until: ' . $until . '<br>');
|
||||||
|
} else {
|
||||||
|
echo($name . ' is not banned.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo($name . ' has not joined before.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
@ -32,4 +32,8 @@ function get_banner_name($banner) {
|
|||||||
return $banner;
|
return $banner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function millis_to_date($millis) {
|
||||||
|
date_default_timezone_set("UTC");
|
||||||
|
return date('F j, Y, g:i a', $millis / 1000);
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -27,9 +27,8 @@
|
|||||||
global $table_mutes, $conn;
|
global $table_mutes, $conn;
|
||||||
$result = run_query($table_mutes);
|
$result = run_query($table_mutes);
|
||||||
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
|
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
|
||||||
date_default_timezone_set("UTC");
|
$timeResult = millis_to_date($row['time']);
|
||||||
$timeResult = date('F j, Y, g:i a', $row['time'] / 1000);
|
$expiresResult = millis_to_date($row['until']);
|
||||||
$expiresResult = date('F j, Y, g:i a', $row['until'] / 1000);
|
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><?php echo get_avatar($row['name']); ?></td>
|
<td><?php echo get_avatar($row['name']); ?></td>
|
||||||
|
@ -34,8 +34,7 @@
|
|||||||
global $table_warnings, $conn;
|
global $table_warnings, $conn;
|
||||||
$result = run_query($table_warnings);
|
$result = run_query($table_warnings);
|
||||||
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
|
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
|
||||||
date_default_timezone_set("UTC");
|
$expiresResult = millis_to_date($row['until']);
|
||||||
$expiresResult = date('F j, Y, g:i a', $row['until'] / 1000);
|
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><?php echo get_avatar($row['name']); ?></td>
|
<td><?php echo get_avatar($row['name']); ?></td>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user