More cleanup

This commit is contained in:
Ruan 2015-07-08 09:17:38 +02:00
parent 4fee252b31
commit 09fff14917
5 changed files with 23 additions and 29 deletions

View File

@ -1,30 +1,10 @@
<?php require './includes/page.php'; ?>
<title>Tempbans - <?php echo $name; ?></title>
<div class="container">
<?php print_page_header("Bans"); ?>
<br/>
<!-- Ban check form -->
<form onsubmit="captureForm(event);" 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 captureForm(e) {
$.ajax({
type: 'POST',
url: 'check.php',
data: {name: document.getElementById('user').value, table: 'bans'}
}).done(function (msg) {
document.getElementById('output').innerHTML = msg;
});
e.preventDefault();
return false;
}
</script>
<div id="output"></div>
<!-- End ban check form -->
<?php
print_page_header("Bans");
print_check_form("bans");
?>
<div class="row" style="margin-bottom:60px;">
<div class="col-lg-12">
<table class="table table-hover table-bordered table-condensed">

View File

@ -2,7 +2,7 @@
if (isset($_POST['name'], $_POST['table'])) {
$name = $_POST['name'];
// validate user input
if (strlen($name) > 16 || !preg_match("/[0-9a-zA-Z_]/", $name)) {
if (strlen($name) > 16 || !preg_match("/^[0-9a-zA-Z_]$/", $name)) {
echo('Invalid name.');
return;
}
@ -21,7 +21,9 @@ if (isset($_POST['name'], $_POST['table'])) {
echo($name . ' has not joined before.');
return;
}
$stmt = $conn->prepare("SELECT * FROM " . $table_bans . " WHERE (uuid=? AND active=1) LIMIT 1");
$table = $table_bans;
$stmt = $conn->prepare("SELECT * FROM " . $table . " WHERE (uuid=? AND active=1) LIMIT 1");
if ($stmt->execute(array($uuid))) {
if (!($row = $stmt->fetch())) {
echo($name . ' is not banned.');
@ -31,7 +33,7 @@ if (isset($_POST['name'], $_POST['table'])) {
$reason = $row['reason'];
$time = millis_to_date($row['time']);
$until = millis_to_date($row['until']);
echo($name . ' is banned! <br>');
echo($name . ' is banned!<br>');
echo('Banned by: ' . $banner . '<br>');
echo('Reason: ' . clean($reason) . '<br>');
echo('Banned on: ' . $time . '<br>');

View File

@ -97,4 +97,12 @@ function print_table_headers($headers) {
echo("<tbody>");
}
function print_check_form($table) {
// var table=document.URL.substring(document.URL.lastIndexOf("/")+1); table=table.substring(0,table.indexOf("."));
echo('<br>');
echo('<form onsubmit="captureForm(event);" 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>');
echo('<script type="text/javascript">function captureForm(b){$.ajax({type:"POST",url:"check.php",data:{name:document.getElementById("user").value,table:"' . $table . '"}}).done(function(c){document.getElementById("output").innerHTML=c});b.preventDefault();return false};</script>');
echo('<div id="output"></div>');
}
?>

View File

@ -1,7 +1,9 @@
<?php require './includes/page.php'; ?>
<title>TempMutes - <?php echo $name; ?></title>
<div class="container">
<?php print_page_header("Mutes"); ?>
<?php
print_page_header("Mutes");
?>
<div class="row" style="margin-bottom:60px;">
<div class="col-lg-12">
<table class="table table-hover table-bordered table-condensed">

View File

@ -1,7 +1,9 @@
<?php require './includes/page.php'; ?>
<title>Warnings - <?php echo $name; ?></title>
<div class="container">
<?php print_page_header("Warnings"); ?>
<?php
print_page_header("Warnings");
?>
<div class="row" style="margin-bottom:60px;">
<div class="col-lg-12">
<table class="table table-hover table-bordered table-condensed">