I want to add a teamspeak server status checker on my website, to check if it is online or offline
is there a way to do it in php, or jquery, javascript or in some other way?
I tried this, in php, but it does not work...
<?php
function check_ts($ip, $tcp, $udp, $timeout=1) { //Function for the Check
$fp = @fsockopen($ip, $tcp, $errno, $errstr, $timeout);
if (!$fp) {
$stat = false;
} else {
if (fgets($fp) == "[TS]
") {
fputs($fp, "SEL $udp
");
if (fgets($fp) == "OK
") {
$stat = true;
} else {
$stat = false;
}
} else {
$stat = false;
}
if (is_resource($fp))
@fclose($fp);
return $stat;
}
}
if (check_ts("my_WAN_ip", 10011, 9987)) { //Change IP, Query-Port and TS-Port
echo "<FONT COLOR=#00DD00><B>ONLINE</B></FONT>";
} else {
echo "<FONT COLOR=#DD0000><B>OFFLINE</B></FONT>";
}
?>
I've also tried different ports found in this post, but it does not work
Please help