<?php
/**
* STRESS WEB
* @author S.T.R.E.S.S.
* @copyright 2008 - 2011 STRESS WEB
* @version 12
* @web http://stressweb.ru
*/
if (!defined("STRESSWEB"))
die("Access denied...");
if ($l2cfg["server"]["enable"])
{
if ($user->GetCache("server_status_time") > $_TIME && $l2cfg["cache"]["enable"])
{
$tpl->result["server"] = $user->GetCache("server_status");
}
else
{
$LS = array();
$Total = 0;
foreach ($lList as $_L)
{
$LS[$_L] = $user->GetStatus($l2cfg["ls"][$_L]["host"], $l2cfg["ls"][$_L]["port"]);
}
$tpl->LoadTemplate("server_item.tpl");
foreach ($sList as $_S)
{
$GS = $user->GetStatus($l2cfg["gs"][$_S]["host"], $l2cfg["gs"][$_S]["port"]);
$db->gdb($_S);
$Online = $user->GetOnline($_S);
if ($l2cfg["gs"][$_S]["fake"]["enable"])
{
$Online = intval($Online * (1 + $l2cfg["gs"][$_S]["fake"]["percent"] / 100));
}
$tpl->SetVar("{THEME}", TPL_DIR);
$slink = ($l2cfg["mod_rewrite"]) ? HTTP_HOME_URL."stat/s{$_S}":HTTP_HOME_URL."index.php?f=stat&sid={$_S}";
$tpl->SetVar("{nameLink}", "<a href='{$slink}'>{$l2cfg["gs"][$_S]["title"]}</a>");
$tpl->SetVar("{name}", "{$l2cfg["gs"][$_S]["title"]}");
$tpl->SetVar("{online}", $Online);
$tpl->SetVar("{login}", $LS[$l2cfg["gs"][$_S]["ls"]]);
$tpl->SetVar("{game}", $GS);
$tpl->SetVar("{chronicle}", $l2cfg["gs"][$_S]["chronicle"]);
$tpl->build("server_item");
$Total += $Online;
if ($l2cfg["txt"]["enable"] and $l2cfg["txt"]["gs"] == $_S)
{
$fopen = fopen(ROOT_DIR.'/online.txt', "w");
if ($fopen)
{
fwrite($fopen, $Online);
fclose($fopen);
}
}
}
$tpl->clear();
$tpl->LoadTemplate("server.tpl");
$tpl->SetVar("{THEME}", TPL_DIR);
if (isset($LS[0]))
$tpl->SetVar("{login}", $LS[0]);
$tpl->SetVar("{server_item}", $tpl->result["server_item"]);
if ($l2cfg["gs"]["count"] > 1)
{
$tpl->SetBlock("'\\[total\\](.*?)\\[/total\\]'si", "\\1");
$tpl->SetVar("{total}", $Total);
}
else
$tpl->SetBlock("'\\[total\\](.*?)\\[/total\\]'si", "");
$tpl->build("server");
$tpl->clear();
if ($l2cfg["cache"]["enable"])
{
$user->SetCache("server_status_time", $_TIME + 60 * $l2cfg["cache"]["sList"]);
$user->SetCache("server_status", $tpl->result["server"]);
}
}
}
else
$tpl->result["server"] = "Статус серверов временно не доступен";
?>