I have this PHP widget to output game servers status:
PHP Code:
error_reporting(E_ALL);
require_once 'GameQ.php';
// Define your servers,
// see list.php for all supported games and identifiers.
$servers = array(
'server 1' => array('tf2', 'localhost'),
'server 2' => array('tf2', 'localhost')
);
// Call the class, and add your servers.
$gq = new GameQ();
$gq->addServers($servers);
// You can optionally specify some settings
$gq->setOption('timeout', 200);
// You can optionally specify some output filters,
// these will be applied to the results obtained.
$gq->setFilter('normalise');
$gq->setFilter('sortplayers', 'gq_ping');
// Send requests, and parse the data
$results = $gq->requestData();
// Some functions to print the results
function print_results($results) {
foreach ($results as $id => $data) {
printf("<h2>%s</h2>\n", $id);
print_table($data);
}
}
function print_table($data) {
$gqs = array('gq_online', 'gq_address', 'gq_port', 'gq_prot', 'gq_type');
if (!$data['gq_online']) {
printf("<p>The server did not respond within the specified time.</p>\n");
return;
}
print("<h1>$data[hostname]</h1>");
print("<h1>$data[gamename]</h1>");
print("<h3>$data[gq_mapname]</h3>");
print("<h3>$data[gq_gametype]</h3>");
print("<h3>$data[game_descr]</h3>");
print("<h3>$data[gq_address]</h3>");
print("");
foreach ($data as $key => $val) {
if (is_array($val)) continue;
$cls = empty($cls) ? ' class="uneven"' : '';
if (substr($key, 0, 3) == 'gq_') {
$kcls = (in_array($key, $gqs)) ? 'always' : 'normalise';
$key = sprintf("<span class=\"key-%s\">%s</span>", $kcls, $key);
}
printf("", $cls, $key, $val);
}
print("</tbody></table>\n");
}
It works outside the widget system in a simple PHP page, but I want to put the results in a widget. The var that I want is the $results, how can I output it to the vbcms_widget_execphp_page template?
Thanks