palp
31-05-2003, 20:00
I'm running webpost and teamspeak on the same server, so I wanted to have my data more up-to-date than a 5 minute interval. So, I set to work to do just this.
You can't change how often Teamspeak sends out the webpost data. However, the detail data - channels and users - is handled with TCPQuery and can be controlled. I set mine up so that the data there refreshes each time the details page is reloaded. I'm also working on using that information to update the normal data as well (i.e. number of active users) so that it doesn't appear out-of-sync.
In doing this, I also came across an issue - the "servertimeout" value in the config file also dictates timeouts for things like players and channels. So, a player can show up as logged in for as long as 15 minutes after they've left the server. I fixed this as well, by having it check timestamps each time it updates the player and channel lists. If a player or channel was last updated before the update began, then they're no longer logged in, and are removed from the listing.
Overall, the modifications are fairly minor.
I recommend backing up your db_inc.php before you do this in case something goes wrong, especially if you are not familiar with PHP (as in, you have no idea what you're doing :) )
In db_inc.php, line 83, replace the getserverdetail() function with this one:
function getserverdetail($var1) {
require("config_inc.php");
$detaildata = fetch_line("SELECT * FROM $dbtable WHERE server_id='$var1'");
if ($detaildata[11]) {
insertchannelinfo($detaildata[10], $detaildata[21], $detaildata[11]);
insertuserinfo($detaildata[10], $detaildata[21], $detaildata[11]);
}
include("tpl_serverdetail.php");
}
That's all that is required to make the TCPQuery data update every refresh.
If you want to fix the issue with stale players/channels, do the following (the line numbers here assume you have made the modification above):
The insertchannelinfo function begins on line 293. Below the line:
global $server_timestamp;
add:
$now = $server_timestamp;
Then, insert a line just before the last closing brace of that function, on what will now be line 348:
query("delete from $dbtable3 where server_timestamp < '$now'");
Next, you have to do the same thing to the insertuserinfo function, which begins on what is now line 351. Just as before, below the line:
global $server_timestamp;
add:
$now = $server_timestamp;
And before the last closing brace, which is now line 420, add this(note that this code is slightly different than that for the channel info, make sure you use the right one!):
query("delete from $dbtable2 where server_timestamp < '$now'");
And that should do it. Any questions, feel free to ask.
You can't change how often Teamspeak sends out the webpost data. However, the detail data - channels and users - is handled with TCPQuery and can be controlled. I set mine up so that the data there refreshes each time the details page is reloaded. I'm also working on using that information to update the normal data as well (i.e. number of active users) so that it doesn't appear out-of-sync.
In doing this, I also came across an issue - the "servertimeout" value in the config file also dictates timeouts for things like players and channels. So, a player can show up as logged in for as long as 15 minutes after they've left the server. I fixed this as well, by having it check timestamps each time it updates the player and channel lists. If a player or channel was last updated before the update began, then they're no longer logged in, and are removed from the listing.
Overall, the modifications are fairly minor.
I recommend backing up your db_inc.php before you do this in case something goes wrong, especially if you are not familiar with PHP (as in, you have no idea what you're doing :) )
In db_inc.php, line 83, replace the getserverdetail() function with this one:
function getserverdetail($var1) {
require("config_inc.php");
$detaildata = fetch_line("SELECT * FROM $dbtable WHERE server_id='$var1'");
if ($detaildata[11]) {
insertchannelinfo($detaildata[10], $detaildata[21], $detaildata[11]);
insertuserinfo($detaildata[10], $detaildata[21], $detaildata[11]);
}
include("tpl_serverdetail.php");
}
That's all that is required to make the TCPQuery data update every refresh.
If you want to fix the issue with stale players/channels, do the following (the line numbers here assume you have made the modification above):
The insertchannelinfo function begins on line 293. Below the line:
global $server_timestamp;
add:
$now = $server_timestamp;
Then, insert a line just before the last closing brace of that function, on what will now be line 348:
query("delete from $dbtable3 where server_timestamp < '$now'");
Next, you have to do the same thing to the insertuserinfo function, which begins on what is now line 351. Just as before, below the line:
global $server_timestamp;
add:
$now = $server_timestamp;
And before the last closing brace, which is now line 420, add this(note that this code is slightly different than that for the channel info, make sure you use the right one!):
query("delete from $dbtable2 where server_timestamp < '$now'");
And that should do it. Any questions, feel free to ask.