Code:
<html>
<head>
<title>ME-TS.PL - Status Crawl Date</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<?php
require_once("config.php");
require_once("lang.php");
require_once("ts3_lib/TeamSpeak3.php");
try
{
$ts3_ServerInstance = TeamSpeak3::factory("serverquery://".$cfg["user"].":".$cfg["pass"]."@".$cfg["host"].":".$cfg["query"]."/");
$ts3_VirtualServer = TeamSpeak3::factory("serverquery://".$cfg["user"].":".$cfg["pass"]."@".$cfg["host"].":".$cfg["query"]."/?server_port=".$cfg["voice"]);
require_once("mysql_connect.php");
$ts3_VirtualServer->selfUpdate(array('client_nickname'=>$queryname));
$todaydate = time();
$icontime = $todaydate - $warntime;
echo "<table>";
foreach($ts3_VirtualServer->channelList() as $channel)
{
$channelid = $channel->getId();
$channel = $ts3_VirtualServer->channelGetById($channelid);
$channelname = htmlspecialchars($channel);
$userinchannel = $channel["total_clients"];
$channelpath = $channel->getPathway();
$datetime = date('Y-m-d H:i:s');
$channelpath_in = addslashes($channelpath);
echo "<tr>";
echo "<td>".$lang['cid'].$channelid." : </td>";
echo "<td>".$channelname."</td>";
$cidexists = mysql_fetch_row(mysql_query("SELECT COUNT(*) FROM $table_channel WHERE cid='$channelid'"));
if($cidexists[0]>0)
{
if($userinchannel>0)
{
echo "<td><span class=\"green\">".$lang['cidup1'].$userinchannel.$lang['cidup2']."</span></td></tr>";
mysql_query("UPDATE $table_channel SET lastuse='$datetime',path='$channelpath' WHERE cid='$channelid'");
$checkicon=$ts3_VirtualServer->channelPermList($channelid,$permsid=FALSE);
foreach($checkicon as $rows)
{
if($rows["permvalue"]=="301694691")
{
$ts3_VirtualServer->channelPermRemove($channelid, 142);
}
}
}
else
{
$lastusetime = mysql_fetch_row(mysql_query("SELECT lastuse FROM $table_channel WHERE cid='$channelid'"));
$lastusetime=strtotime($lastusetime[0]);
echo "<td><span class=\"red\">".$lang['cidnoup']."</span></td>";
if($seticon==1)
{
if(!in_array($channelid, $nodelete))
{
if($lastusetime<$icontime)
{
$checkspacer = $ts3_VirtualServer->channelIsSpacer($channel);
if ($checkspacer!=1)
{
$children = $channel->getChildren();
if($children=="")
{
echo "<td><span class=\"blue\">".$lang['seticon']."</span></td>";
$ts3_VirtualServer->channelPermAssign($channelid, 142, 301694691);
}
}
}
}
}
echo "</tr>";
}
}
else
{
echo "<td><span class=\"blue\">".$lang['record']."</span></td></tr>";
mysql_query("INSERT INTO $table_channel (`id`,`cid`,`lastuse`,`path`) VALUES ('','$channelid','$datetime','$channelpath_in')");
}
}
echo "</table>";
}
catch(Exception $e)
{
echo "<span class='error'><b>".$lang['error'].$e->getCode().":</b> ".$e->getMessage()."</span>\n";
}
?>
</body>
</html>