2016-06-28 21:18:59 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once __DIR__ . '/../config/config.php';
|
|
|
|
require_once __DIR__ . "/../lib/ts3phpframework/libraries/TeamSpeak3/TeamSpeak3.php";
|
|
|
|
|
|
|
|
function pingTeamspeakServerFromConfig() {
|
2017-02-01 15:31:32 +00:00
|
|
|
return pingTeamspeakServer(getTeamspeakConnection("?use_offline_as_virtual=1&no_query_clients=1"));
|
2016-06-28 21:18:59 +00:00
|
|
|
}
|
|
|
|
|
2017-02-01 15:31:32 +00:00
|
|
|
function pingTeamspeakServer() {
|
2016-06-28 21:18:59 +00:00
|
|
|
try {
|
2017-02-01 15:31:32 +00:00
|
|
|
$tsAdmin = getTeamspeakConnection();
|
2016-07-01 20:34:55 +00:00
|
|
|
|
2017-02-01 15:31:32 +00:00
|
|
|
if ($tsAdmin->isOffline())
|
2016-06-28 21:18:59 +00:00
|
|
|
throw new Exception("Server is offline");
|
2016-07-01 20:34:55 +00:00
|
|
|
|
2016-06-28 21:18:59 +00:00
|
|
|
return $tsAdmin->getInfo();
|
2016-10-31 02:18:46 +00:00
|
|
|
} catch (TeamSpeak3_Exception $e) {
|
2016-06-28 21:18:59 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-01 15:31:32 +00:00
|
|
|
function getTeamspeakConnection($arguments = '') {
|
|
|
|
try {
|
|
|
|
global $config;
|
|
|
|
$host = $config['teamspeak']['host'];
|
|
|
|
$login = $config['teamspeak']['login'];
|
|
|
|
$passwd = $config['teamspeak']['password'];
|
|
|
|
$sport = $config['teamspeak']['server_port'];
|
|
|
|
$qport = $config['teamspeak']['query_port'];
|
|
|
|
|
|
|
|
$tsNodeHost = TeamSpeak3::factory("serverquery://$host:$qport/$arguments");
|
|
|
|
$tsNodeHost->login($login, $passwd);
|
|
|
|
return $tsNodeHost->serverGetByPort($sport);
|
|
|
|
} catch (Exception $e) {
|
|
|
|
throw $e;
|
|
|
|
}
|
2016-06-28 21:18:59 +00:00
|
|
|
}
|