|
|
@ -4,29 +4,35 @@ require_once __DIR__ . '/../config/config.php';
|
|
|
|
require_once __DIR__ . "/../lib/ts3phpframework/libraries/TeamSpeak3/TeamSpeak3.php";
|
|
|
|
require_once __DIR__ . "/../lib/ts3phpframework/libraries/TeamSpeak3/TeamSpeak3.php";
|
|
|
|
|
|
|
|
|
|
|
|
function pingTeamspeakServerFromConfig() {
|
|
|
|
function pingTeamspeakServerFromConfig() {
|
|
|
|
return pingTeamspeakServer(getTeamspeakURI() . "&use_offline_as_virtual=1&no_query_clients=1");
|
|
|
|
return pingTeamspeakServer(getTeamspeakConnection("?use_offline_as_virtual=1&no_query_clients=1"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function pingTeamspeakServer($uri) {
|
|
|
|
function pingTeamspeakServer() {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
$tsAdmin = TeamSpeak3::factory($uri);
|
|
|
|
$tsAdmin = getTeamspeakConnection();
|
|
|
|
|
|
|
|
|
|
|
|
if (!$tsAdmin->getProperty("virtualserver_status"))
|
|
|
|
if ($tsAdmin->isOffline())
|
|
|
|
throw new Exception("Server is offline");
|
|
|
|
throw new Exception("Server is offline");
|
|
|
|
|
|
|
|
|
|
|
|
return $tsAdmin->getInfo();
|
|
|
|
return $tsAdmin->getInfo();
|
|
|
|
} catch (TeamSpeak3_Exception $e) {
|
|
|
|
} catch (TeamSpeak3_Exception $e) {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function getTeamspeakURI() {
|
|
|
|
function getTeamspeakConnection($arguments = '') {
|
|
|
|
global $config;
|
|
|
|
try {
|
|
|
|
$host = $config['teamspeak']['host'];
|
|
|
|
global $config;
|
|
|
|
$login = $config['teamspeak']['login'];
|
|
|
|
$host = $config['teamspeak']['host'];
|
|
|
|
$passwd = $config['teamspeak']['password'];
|
|
|
|
$login = $config['teamspeak']['login'];
|
|
|
|
$sport = $config['teamspeak']['server_port'];
|
|
|
|
$passwd = $config['teamspeak']['password'];
|
|
|
|
$qport = $config['teamspeak']['query_port'];
|
|
|
|
$sport = $config['teamspeak']['server_port'];
|
|
|
|
return "serverquery://$login:$passwd@$host:$qport/?server_port=$sport";
|
|
|
|
$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;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|