Simplify settings, clean up

This commit is contained in:
Ruan 2015-03-12 08:07:21 +02:00
parent 0eb17d9c1e
commit 15d5e9706a
9 changed files with 84 additions and 88 deletions

View File

@ -1,8 +1,5 @@
<?php require 'includes/page.php'; ?>
<head>
<title>Tempbans - <?php echo $name; ?></title>
</head>
<body>
<title>Tempbans - <?php echo $name; ?></title>
<div class="container">
<div class="row">
<div class="col-lg-12">
@ -37,6 +34,7 @@
</thead>
<tbody>
<?php
global $table_bans, $conn;
$result = run_query($table_bans);
while ($row = $result->fetch_assoc()) {
date_default_timezone_set("UTC");

View File

@ -1,39 +0,0 @@
<?php
// Server host
$dbhost = 'localhost';
// Username/password
$username = 'root';
$password = 'password';
// Database name
$database = 'litebans';
// Show inactive bans? Removed bans will show (Unbanned), mutes will show (Unmuted), warnings will show (Inactive).
$show_inactive_bans = true;
// Amount of bans/mutes/warnings to show on each page
$limit_per_page = 20;
// If you set a table prefix in config.yml, put it here too
$table_prefix = "";
/*****************************************************************************/
$conn = new mysqli($dbhost, $username, $password, $database);
$table_bans = $table_prefix . "bans";
$table_mutes = $table_prefix . "mutes";
$table_warnings = $table_prefix . "warnings";
$table_history = $table_prefix . "history";
if ($conn->connect_errno > 0) {
die('Unable to connect to database: ' . $conn->connect_error);
}
$active_query = "WHERE active=1";
if ($show_inactive_bans) {
$active_query = "";
}
?>

View File

@ -1,12 +0,0 @@
<?php
// <<---------Ban Listing Settings (Simplified)--------->> //
$name = 'LiteBans';
$serverip = 'mc.example.com';
function get_banner_name($banner) {
if ($banner === "CONSOLE") {
return "Console";
}
return $banner;
}
?>

View File

@ -1,15 +1,13 @@
<?php require 'includes/data/settings.php'; ?>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="LiteBans">
<link rel="shortcut icon" href="includes/img/minecraft.ico">
<link href="includes/css/bootstrap.css" rel="stylesheet">
<link href="includes/css/navbar-fixed-top.css" rel="stylesheet">
<style>
<?php require 'settings.php'; ?>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="LiteBans">
<link rel="shortcut icon" href="includes/img/minecraft.ico">
<link href="includes/css/bootstrap.css" rel="stylesheet">
<link href="includes/css/navbar-fixed-top.css" rel="stylesheet">
<style>
html {
background-image: url('includes/img/377759.png');
}
</style>
</head>
</style>

View File

@ -1,7 +1,9 @@
<?php
require 'head.php';
require 'header.php';
require 'data/database.php';
require 'settings.php';
connect();
function get_query($table) {
global $table_history, $active_query, $limit_per_page;
@ -12,7 +14,7 @@ function get_query($table) {
function run_query($table) {
global $conn;
if (!$result = $conn->query(get_query($table))) {
die('Query error [' . $conn->error . ']');
die('Query error: "' . $conn->error . '"');
}
return $result;
}
@ -21,4 +23,11 @@ function get_avatar($name) {
return "<img src='https://minotar.net/avatar/" . $name . "/25' style='margin-bottom:5px;margin-right:5px;border-radius:2px;' />" . $name;
}
function get_banner_name($banner) {
if ($banner === "CONSOLE") {
return "Console";
}
return $banner;
}
?>

52
includes/settings.php Normal file
View File

@ -0,0 +1,52 @@
<?php
/** Server settings **/
$name = 'LiteBans';
$serverip = 'mc.example.com';
/** MySQL settings **/
// Server host
$dbhost = 'localhost';
$username = 'root';
$password = 'password';
// Database name
$database = 'litebans';
// Show inactive bans? Removed bans will show (Unbanned), mutes will show (Unmuted), warnings will show (Inactive).
$show_inactive_bans = true;
// Amount of bans/mutes/warnings to show on each page
$limit_per_page = 20;
// If you set a table prefix in config.yml, put it here too
$table_prefix = "";
/*****************************************************************************/
function connect() {
// imported
global $dbhost, $username, $password, $database, $table_prefix, $show_inactive_bans;
// exported
global $conn, $active_query;
global $table_bans, $table_mutes, $table_warnings, $table_history;
$conn = new mysqli($dbhost, $username, $password, $database);
$table_bans = $table_prefix . "bans";
$table_mutes = $table_prefix . "mutes";
$table_warnings = $table_prefix . "warnings";
$table_history = $table_prefix . "history";
if ($conn->connect_errno > 0) {
die('Unable to connect to database: ' . $conn->connect_error);
}
$active_query = "WHERE active=1";
if ($show_inactive_bans) {
$active_query = "";
}
}
?>

View File

@ -1,10 +1,6 @@
<?php include 'includes/head.php'; ?>
<?php include 'includes/header.php'; ?>
<head>
<title>Index - <?php echo $name; ?></title>
</head>
<body>
<title>Index - <?php echo $name; ?></title>
<div class="container">
<div class="jumbotron">
<div style="text-align: center;"><h2>Welcome to <?php echo $name; ?>'s Ban List.</h2></div>
@ -13,6 +9,4 @@
</div>
</div>
<?php
include 'includes/footer.php';
?>
<?php include 'includes/footer.php'; ?>

View File

@ -1,8 +1,5 @@
<?php require 'includes/page.php'; ?>
<head>
<title>TempMutes - <?php echo $name; ?></title>
</head>
<body>
<title>TempMutes - <?php echo $name; ?></title>
<div class="container">
<div class="row">
<div class="col-lg-12">
@ -27,6 +24,7 @@
</thead>
<tbody>
<?php
global $table_mutes, $conn;
$result = run_query($table_mutes);
while ($row = $result->fetch_assoc()) {
date_default_timezone_set("UTC");

View File

@ -1,8 +1,5 @@
<?php require 'includes/page.php'; ?>
<head>
<title>Warnings - <?php echo $name; ?></title>
</head>
<body>
<title>Warnings - <?php echo $name; ?></title>
<div class="container">
<div class="row">
<div class="col-lg-12">
@ -34,6 +31,7 @@
</thead>
<tbody>
<?php
global $table_warnings, $conn;
$result = run_query($table_warnings);
while ($row = $result->fetch_assoc()) {
date_default_timezone_set("UTC");