Initial commit
This commit is contained in:
74
include/adminlist.php
Normal file
74
include/adminlist.php
Normal file
@ -0,0 +1,74 @@
|
||||
<?php
|
||||
$bansPage = true;
|
||||
require_once __DIR__ . "/tsutils.php";
|
||||
require_once __DIR__ . "/../lib/phpfastcache/autoload.php";
|
||||
|
||||
|
||||
|
||||
use phpFastCache\Util;
|
||||
use phpFastCache\CacheManager;
|
||||
|
||||
Util\Languages::setEncoding("UTF-8");
|
||||
$cache = CacheManager::Files();
|
||||
|
||||
$adminlist = $cache->get('adminlist');
|
||||
|
||||
// $cache->clean();
|
||||
|
||||
if (is_null($adminlist)) {
|
||||
$adminlist = array(getAdminList(), date('d-m-Y H:i:s'));
|
||||
$cache->set('adminlist', $adminlist, 30);
|
||||
}
|
||||
|
||||
// FUNCTIONS
|
||||
|
||||
function getAdminList() {
|
||||
|
||||
try {
|
||||
$tsAdmin = TeamSpeak3::factory(getTeamspeakURI(). "#no_query_clients");
|
||||
$serverGroupList = $tsAdmin->serverGroupList();
|
||||
|
||||
$output = "";
|
||||
|
||||
foreach ($serverGroupList as $group) {
|
||||
|
||||
if(!isAdminGroup($group->getId()))
|
||||
continue;
|
||||
|
||||
$output .= "<p class=\"groupname\">$group</p>";
|
||||
|
||||
foreach ($group->clientList() as $userInfo) {
|
||||
$user = getClientByDbid($tsAdmin, $userInfo['cldbid']);
|
||||
|
||||
if(!$user) {
|
||||
$output .= '<p><span class="label label-primary iconspacer">' . $userInfo['client_nickname'] . '</span><span class="label label-danger pullright">Offline</span></p>';
|
||||
continue;
|
||||
}
|
||||
|
||||
$output .= '<p>' . '<img src="lib/ts3phpframework/images/viewer/' . $user->getIcon() . '.png">' . '<span class="label label-primary">' . $user . '</span>' . ($user['client_away'] ? '<span class="label label-warning pullright">Away</span>' : '<span class="label label-success pullright">Online</span>') . '</p>';
|
||||
}
|
||||
}
|
||||
|
||||
return $output;
|
||||
} catch(TeamSpeak3_Exception $e) {
|
||||
return '<div class="alert alert-danger"><p class="text-center">Wystąpił błąd ' . $e->getCode() . ': ' . $e->getMessage() . '</p></div>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function isAdminGroup($groupid) {
|
||||
global $config;
|
||||
$admingroups = $config["adminlist"];
|
||||
|
||||
return in_array($groupid, $admingroups);
|
||||
}
|
||||
|
||||
function getClientByDbid($tsAdmin, $cldbid) {
|
||||
try {
|
||||
return $tsAdmin->clientGetByDbid($cldbid);
|
||||
} catch(TeamSpeak3_Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// echo getAdminList();
|
53
include/configcheck.php
Normal file
53
include/configcheck.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php if(!file_exists(__DIR__ . "/../config/config.php")) { ?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="pl">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<meta name="description" content="Brak wymaganych rozszerzeń">
|
||||
<meta name="author" content="Wruczek">
|
||||
|
||||
<title>BŁĄD: Brak pliku config.php</title>
|
||||
|
||||
<!-- Icon -->
|
||||
<link rel="shortcut icon" href="https://assets-cdn.github.com/images/icons/emoji/unicode/26a0.png">
|
||||
|
||||
<!-- Twitter Bootstrap -->
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.6/superhero/bootstrap.min.css" rel="stylesheet">
|
||||
|
||||
<!--[if IE]>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<style>
|
||||
body { margin-top: 70px }
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container">
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title"><img src="https://assets-cdn.github.com/images/icons/emoji/unicode/26a0.png" width="20px">Brak pliku config.php</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<p>Przejdź do folderu <code>config</code> i zmień nazwę pliku z <code>config.template.php</code> na <code>config.php</code>.</p>
|
||||
<p>Skonfiguruj stronę według własnych potrzeb.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- /container -->
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
<?php
|
||||
die();
|
||||
}
|
47
include/footer.php
Normal file
47
include/footer.php
Normal file
@ -0,0 +1,47 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Footer -->
|
||||
<hr>
|
||||
<footer>
|
||||
<p class="pull-left">© <a href="http://wruczek.top">Wruczek</a> 2016</p>
|
||||
<div class="pull-right">
|
||||
<ul class="list-inline">
|
||||
<li><a href="https://github.com/Wruczek/ts-website">ts-website</a> v 1.0.0 | MIT License</li>
|
||||
</ul>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
<!-- /container -->
|
||||
|
||||
<!-- ################ -->
|
||||
<!-- # JAVASCRIPT # -->
|
||||
<!-- ################ -->
|
||||
|
||||
<!-- jQuery -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
|
||||
|
||||
<!-- Twitter Bootstrap -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Readmore.js -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/Readmore.js/2.2.0/readmore.min.js"></script>
|
||||
|
||||
<?php if(isset($bansPage)) { ?>
|
||||
<!-- DataTables for Bootstrap -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.12/js/jquery.dataTables.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.12/js/dataTables.bootstrap.min.js"></script>
|
||||
<script src="js/bans.js"></script>
|
||||
<?php } ?>
|
||||
|
||||
<!-- Custom JS -->
|
||||
<script src="js/script.js"></script>
|
||||
<script src="js/status.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
<?php
|
||||
$end = microtime(true);
|
||||
$creationtime = ($end - $start);
|
||||
printf("<!-- Page generated " . date('d-m-Y H:i:s') . " in %.6f seconds. -->", $creationtime);
|
||||
?>
|
130
include/header.php
Normal file
130
include/header.php
Normal file
@ -0,0 +1,130 @@
|
||||
<?php
|
||||
$start = microtime(true);
|
||||
require_once __DIR__ . "/configcheck.php";
|
||||
require_once __DIR__ . "/modulecheck.php";
|
||||
require_once __DIR__ . "/../config/config.php";
|
||||
require_once __DIR__ . "/../include/adminlist.php";
|
||||
// require_once __DIR__ . "/include/adminlist.php";
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="pl">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<meta name="description" content="<?php echo $config["general"]["desc"]; ?>">
|
||||
<meta name="author" content="Wruczek">
|
||||
|
||||
<title><?php echo $config["general"]["title"] . $config["general"]["subtitle"]; ?></title>
|
||||
|
||||
<!-- Icon -->
|
||||
<link rel="shortcut icon" href="img/icon/icon-64.png">
|
||||
|
||||
<!-- Bootswatch -->
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.6/superhero/bootstrap.min.css" rel="stylesheet">
|
||||
|
||||
<!-- Font Awesome -->
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet">
|
||||
|
||||
<?php if(isset($bansPage)) { ?>
|
||||
<!-- DataTables for Bootstrap -->
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.12/css/dataTables.bootstrap.min.css" rel="stylesheet">
|
||||
<?php } ?>
|
||||
|
||||
<!-- Custom CSS -->
|
||||
<link href="css/navbar.css" rel="stylesheet">
|
||||
<link href="css/style.css" rel="stylesheet">
|
||||
|
||||
<!--[if IE]>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<nav class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="container">
|
||||
<!-- Brand and toggle get grouped for better mobile display -->
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
|
||||
<span class="sr-only">Nawigacja</span>
|
||||
<i class="fa fa-bars fa-lg" aria-hidden="true"></i>
|
||||
</button>
|
||||
|
||||
<a class="navbar-brand" href="."><img style="width: 64px;" src="img/icon/icon-64.png" alt="Logo strony"><?php echo $config["general"]["title"]; ?></a>
|
||||
</div>
|
||||
|
||||
<!-- Collect the nav links, forms, and other content for toggling -->
|
||||
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
|
||||
<ul class="nav navbar-nav">
|
||||
<li><a href="viewer"><i class="fa fa-eye" aria-hidden="true"></i> Podgląd serwera</a></li>
|
||||
<li><a href="bans"><i class="fa fa-ban" aria-hidden="true"></i> Lista banów</a></li>
|
||||
<!-- Nie mam na to czasu
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><i class="fa fa-television" aria-hidden="true"></i></i>Ranking <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="#"><i class="fa fa-clock-o" aria-hidden="true"></i>Ranking Aktywności</a></li>
|
||||
<li><a href="#"><i class="fa fa-sign-in" aria-hidden="true"></i>Ranking Połaczeń</a></li>
|
||||
<li><a href="#"><i class="fa fa-sign-out" aria-hidden="true"></i>Ranking Połączenia</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
-->
|
||||
</ul>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<?php foreach ($config["navlinks"] as $navlink) {
|
||||
$icon = $navlink[0];
|
||||
$text = $navlink[1];
|
||||
$link = $navlink[2]; ?>
|
||||
<li><a href="<?php echo $link; ?>"><i class="fa <?php echo $icon; ?>" aria-hidden="true"></i> <?php echo $text; ?></a></li>
|
||||
<?php } ?>
|
||||
|
||||
<li data-toggle="tooltip" data-placement="bottom" title="Kontaktuj się z nami pod adresem <?php echo $config["general"]["contactEmail"]; ?>"><a href="mailto:<?php echo $config["general"]["contactEmail"]; ?>"><i class="fa fa-envelope" aria-hidden="true"></i>Kontakt</a></li>
|
||||
|
||||
<li data-toggle="tooltip" data-placement="bottom" title="Kliknij, by połączyć się z serwerem <?php echo $config['teamspeak']['displayip']; ?>"><a href="ts3server://<?php echo $config['teamspeak']['displayip']; ?>"><i class="fa fa-sign-in" aria-hidden="true"></i>Połącz z serwerem</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<!-- /.navbar-collapse -->
|
||||
</div>
|
||||
<!-- /.container-fluid -->
|
||||
</nav>
|
||||
|
||||
<div class="container">
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="col-md-3 col-md-push-9">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading"><i class="fa fa-bar-chart" aria-hidden="true"></i> Status serwera</div>
|
||||
<div class="panel-body">
|
||||
<div class="serverstatus">
|
||||
<p><i class="fa fa-globe" aria-hidden="true"></i> Adres: <a href="ts3server://<?php echo $config['teamspeak']['displayip']; ?>"><?php echo $config['teamspeak']['displayip']; ?></a></p>
|
||||
<div id="serverstatus">
|
||||
<div class="text-center">
|
||||
<i class="fa fa-refresh fa-spin fa-3x fa-fw"></i>
|
||||
<span class="sr-only">Ładowanie...</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading"><i class="fa fa-shield" aria-hidden="true"></i> Status administracji <span class="pullright"><i class="fa fa-question-circle" aria-hidden="true" data-toggle="tooltip" data-placement="bottom" title="Stan na <?php echo $adminlist[1]; ?>"></i></span></div>
|
||||
<div class="panel-body adminlist">
|
||||
<?php echo $adminlist[0]; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading"><i class="fa fa-eye" aria-hidden="true"></i> Podgląd serwera</div>
|
||||
<div class="panel-body">
|
||||
<a href="viewer" class="btn btn-primary btn-lg btn-block"><i class="fa fa-eye" aria-hidden="true"></i> Zobacz »</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-9 col-md-pull-3">
|
59
include/modulecheck.php
Normal file
59
include/modulecheck.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php if(!in_array('mod_rewrite', apache_get_modules())) { ?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="pl">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<meta name="description" content="Brak wymaganych rozszerzeń">
|
||||
<meta name="author" content="Wruczek">
|
||||
|
||||
<title>BŁĄD: Brak wymaganych rozszerzeń</title>
|
||||
|
||||
<!-- Icon -->
|
||||
<link rel="shortcut icon" href="https://assets-cdn.github.com/images/icons/emoji/unicode/26a0.png">
|
||||
|
||||
<!-- Twitter Bootstrap -->
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.6/superhero/bootstrap.min.css" rel="stylesheet">
|
||||
|
||||
<!--[if IE]>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<style>
|
||||
body { margin-top: 70px }
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container">
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title"><img src="https://assets-cdn.github.com/images/icons/emoji/unicode/26a0.png" width="20px">Brak wymaganych rozszerzeń</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<p>Na swoim serwerze nie posiadasz modułu <code>rewrite</code> wymaganego do poprawnego działania tej strony.</p>
|
||||
<p>Posiadasz system Ubuntu? Świetnie! Uruchom poniższe komendy, by włączyć wymagany moduł:</p>
|
||||
<pre>sudo a2enmod rewrite
|
||||
sudo service apache2 reload</pre>
|
||||
<p>Używasz system Debian? Uruchom owe komendy pomijając przedrostek <code>sudo</code>:</p>
|
||||
<pre>a2enmod rewrite
|
||||
service apache2 reload</pre>
|
||||
<p>Jeśli używasz hostingu i nie masz dostępu do konsoli, skontaktuj się z administratorem lub pomocą techniczną Twojego hostingu.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- /container -->
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
<?php
|
||||
die();
|
||||
}
|
32
include/tsutils.php
Normal file
32
include/tsutils.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../config/config.php';
|
||||
require_once __DIR__ . "/../lib/ts3phpframework/libraries/TeamSpeak3/TeamSpeak3.php";
|
||||
|
||||
function pingTeamspeakServerFromConfig() {
|
||||
return pingTeamspeakServer(getTeamspeakURI() . "&use_offline_as_virtual=1&no_query_clients=1");
|
||||
}
|
||||
|
||||
function pingTeamspeakServer($uri) {
|
||||
try {
|
||||
$tsAdmin = TeamSpeak3::factory($uri);
|
||||
|
||||
if(!$tsAdmin->getProperty("virtualserver_status"))
|
||||
throw new Exception("Server is offline");
|
||||
|
||||
return $tsAdmin->getInfo();
|
||||
} catch(TeamSpeak3_Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function getTeamspeakURI() {
|
||||
global $config;
|
||||
$host = $config['teamspeak']['host'];
|
||||
$login = $config['teamspeak']['login'];
|
||||
$passwd = $config['teamspeak']['password'];
|
||||
$sport = $config['teamspeak']['server_port'];
|
||||
$qport = $config['teamspeak']['query_port'];
|
||||
return "serverquery://$login:$passwd@$host:$qport/?server_port=$sport";
|
||||
}
|
Reference in New Issue
Block a user