<?php
include("cssource_class.php");
include("template_class.php");
set_time_limit(120);
if(isset($_GET['ip']) && isset($_GET['port'])) {
$css = new cssource($_GET['ip'], $_GET['port']);
$css->setSortBy("frags"); // Sort players by Frags (supported: index, time, frags)
$output = $css->status();
$wrap_template = new temp("wrapper");
$wrap_template->replace("net_protocol", $output['net_protocol']);
$wrap_template->replace("ip", $output['ip']);
$wrap_template->replace("port", $output['port']);
$wrap_template->replace("hostname", $output['hostname']);
$wrap_template->replace("map", $output['map']);
$wrap_template->replace("game_dir", $output['game_dir']);
$wrap_template->replace("game_type", $output['game_type']);
$wrap_template->replace("appid", $output['appid']);
$player_status = ($output['num_players'] == $output['max_players']) ? "full" : "notfull";
$wrap_template->replace("player_status", $player_status);
$wrap_template->replace("num_players", $output['num_players']);
$wrap_template->replace("max_players", $output['max_players']);
$wrap_template->replace("bot_players", $output['bot_players']);
$dedicated = ($output['dedicated'] == "d") ? "Yes" : "No";
$wrap_template->replace("dedicated", $dedicated);
$server_os = ($output['server_os'] == "w") ? "Windows" : "Linux";
$wrap_template->replace("server_os", $server_os);
$needpass = ($output['needpass'] == "1") ? "Yes" : "No";
$wrap_template->replace("needpass", $needpass);
$secure = ($output['secure'] == "1") ? "Yes" : "No";
$wrap_template->replace("secure", $secure);
$players_html = "";
foreach($output['players'] AS $player) {
$player_template = new temp("player");
$player_template->replace("index", $player['index']);
$player_template->replace("name", $player['name']);
$player_template->replace("frags", $player['frags']);
$player_template->replace("time", date("H:i:s", $player['time']));
$players_html .= $player_template->show();
}
$wrap_template->replace("players", $players_html);
$rules_html = "";
foreach($output['rules'] AS $rule => $value) {
$rule_template = new temp("rule");
$rule_template->replace("rule", $rule);
$rule_template->replace("value", $value);
$rules_html .= $rule_template->show();
}
$wrap_template->replace("rules", $rules_html);
echo $wrap_template->show();
}
else {
$wrap_template = new temp("wrapper_empty");
echo $wrap_template->show();
}
?>
|