Add configurable console aliases, name, and image

This commit is contained in:
ruan 2015-09-10 17:41:21 +02:00
parent e4de92b925
commit 82a6dcbff0
3 changed files with 25 additions and 6 deletions

BIN
includes/img/console.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 288 B

View File

@ -91,7 +91,12 @@ class Page {
* @return string
*/
function get_avatar($name) {
return "<img class='avatar noselect' src='https://cravatar.eu/avatar/$name/25'/>$name";
$src = "https://cravatar.eu/avatar/$name/25";
if (in_array($name, $this->settings->console_aliases)) {
$src = $this->settings->console_image;
$name = $this->settings->console_name;
}
return "<img class='avatar noselect' src='$src'/>$name";
}
/**
@ -120,12 +125,16 @@ class Page {
*/
function get_banner_name($row) {
$uuid = $row['banned_by_uuid'];
$display_name = $row['banned_by_name'];
$console_aliases = $this->settings->console_aliases;
if (in_array($uuid, $console_aliases) || in_array($row['banned_by_name'], $console_aliases)) {
return $this->settings->console_name;
}
$name = $this->get_name($uuid);
if ($name !== null) {
return $name;
}
$name = $row['banned_by_name'];
return $this->clean($name);
return $this->clean($display_name);
}
/**

View File

@ -1,7 +1,8 @@
<?php
namespace litebans;
use PDO, PDOException;
use PDO;
use PDOException;
final class Settings {
public static $TRUE = "1", $FALSE = "0";
@ -22,6 +23,9 @@ final class Settings {
$username = 'root';
$password = 'password';
// Supported drivers: mysql, pgsql
$driver = 'mysql';
// Show inactive bans? Removed bans will show (Unbanned), mutes will show (Unmuted), warnings will show (Expired).
$this->show_inactive_bans = true;
@ -34,14 +38,20 @@ final class Settings {
// If you set a table prefix in config.yml, set it here as well
$table_prefix = "";
// The server console will be identified by any of these names.
// It will be given a standard name and avatar image.
$this->console_aliases = array(
"CONSOLE", "Console",
);
$this->console_name = "Console";
$this->console_image = "includes/img/console.png";
// The date format can be changed here.
// https://secure.php.net/manual/en/function.date.php
// Example of default: July 2, 2015, 9:19 PM
$this->date_format = 'F j, Y, g:i A';
date_default_timezone_set("UTC");
// Supported drivers: mysql, pgsql
$driver = 'mysql';
/*** End of configuration ***/