Ok,
So on [url]http://target-acquired.org[/url] we are utilizing the SourceQuery PHP Class to retrieve and display the status of our Source Engine Game Servers. For some reason no matter what I do the function still grabs the data from the last time it was called. This is built in as a WordPress shortcode so that it would make it easier to insert in to a given page.
Here is the function:
[PHP]
add_shortcode("srcSrvStatus", "srcSrvStatus");
function srcSrvStatus ($atts)
{
$atts = shortcode_atts(
array(
address => "", // Address of Source Engine Game Server
port => "0", // Port of Source Engine Game Server
)
, $atts);
// Edit this ->
define( 'SQ_SERVER_ADDR', $atts["address"] );
define( 'SQ_SERVER_PORT', $atts["port"] );
define( 'SQ_TIMEOUT', 1 );
define( 'SQ_ENGINE', SourceQuery :: SOURCE );
// Edit this <-
$Query = new SourceQuery( );
try
{
$Query->Connect( SQ_SERVER_ADDR, SQ_SERVER_PORT, SQ_TIMEOUT, SQ_ENGINE );
//print_r( $Query->GetInfo( ) );
$Stats = $Query->GetInfo();
}
catch( Exception $e )
{
echo $e->getMessage( );
}
$Query->Disconnect( );
$Stats["HostName"] = str_replace('Target Acquired | ', '', $Stats["HostName"]);
echo '
<div id="tileDepth1">
<div id="tileDepth2">
<div id="tileDepth3">
<p class="targetHeader">'.$Stats["ModDesc"].'</p>
<p class="targetText">
<ul>
<li>Hostname: '.$atts["address"].'</li>
<li>Port: '.$Stats["GamePort"].'</li>
<li>Current Map: '.$Stats["Map"].'</li>
<li>Name: '.$Stats["HostName"].'</li>
<li>Current Players: '.$Stats["Players"].' / '.$Stats["MaxPlayers"].'</li>
</ul>
</p>
</div>
</div>
</div>
';
unset($Query);
unset($atts);
unset($Stats);
return 0;
}
[/PHP]
This is the shortcode:
[CODE][srcSrvStatus addres="tf2-s1-east.target-acquired.org port="27015"][srcSrvStatus addres="tf2-s1-east.target-acquired.org port="27016"][/CODE]
This is the same thing but how it is coded in the home.php:
[PHP]do_shortcode('[srcSrvStatus addres="tf2-s1-east.target-acquired.org port="27015"]');[/PHP]
On the homepage there are supposed to be two tiles, which there are, but one is supposed to grab data from the Team Fortress 2 server and the other from our Counter-Strike: Source server. I will eventually add checking to see if the server is down and if that is true then the tile will be hidden but I need to sort this bit out first.
Thank You for any and all help in advance!
Sorry, you need to Log In to post a reply to this thread.