You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
TS-Website/include/tsutils.php

39 lines
1.1 KiB

9 years ago
<?php
require_once __DIR__ . '/../config/config.php';
require_once __DIR__ . "/../lib/ts3phpframework/libraries/TeamSpeak3/TeamSpeak3.php";
function pingTeamspeakServerFromConfig() {
return pingTeamspeakServer(getTeamspeakConnection("?use_offline_as_virtual=1&no_query_clients=1"));
9 years ago
}
function pingTeamspeakServer() {
9 years ago
try {
$tsAdmin = getTeamspeakConnection();
if ($tsAdmin->isOffline())
9 years ago
throw new Exception("Server is offline");
9 years ago
return $tsAdmin->getInfo();
} catch (TeamSpeak3_Exception $e) {
9 years ago
return false;
}
}
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;
}
9 years ago
}