My server is offline in gesior and otservlist, can anyone help me? I use TFS 1.5 in Ubuntu 22.04
Layout.php
load.compat.php
Layout.php
PHP:
<?php
if ( ! session_id() ) @ session_start();
$last = null;
if (!isset($_SESSION)) {
$_SESSION = [];
}
if (isset($_SESSION['server_status_last_check'])) {
$last = $_SESSION['server_status_last_check'];
}
if ($last == null || time() > $last + 30) {
$_SESSION['server_status_last_check'] = time();
$_SESSION['server_status'] = $config['status']['serverStatus_online'];
}
$infobar = Website::getWebsiteConfig()->getValue('info_bar_active');
if($_SESSION['server_status'] == 1){
$qtd_players_online = $SQL->prepare("SELECT count(*) as total from `players_online`");
$qtd_players_online->execute([]);
$qtd_players_online = $qtd_players_online->fetch();
if($qtd_players_online["total"] == "1"){
$players_online = ($infobar ? $qtd_players_online["total"].' Player Online' : $qtd_players_online["total"].'<br/>Player Online');
}else{
$players_online = ($infobar ? $qtd_players_online["total"].' Players Online' : $qtd_players_online["total"].'<br/>Players Online');
}
}
else{
$players_online = ($infobar ? 'Server Offline' : 'Server<br/>Offline');
}
?>
load.compat.php
PHP:
// STATUS CHECKER
$statustimeout = 1;
foreach (explode("*", str_replace(" ", "", $config['server']['statusTimeout'])) as $status_var)
if ($status_var > 0)
$statustimeout = $statustimeout * $status_var;
$statustimeout = $statustimeout / 1000;
$config['status'] = parse_ini_string(file_get_contents('cache/DONT_EDIT_serverstatus.txt'));
if ($config['status']['serverStatus_lastCheck'] + $statustimeout < time()) {
$config['status']['serverStatus_checkInterval'] = $statustimeout + 3;
$config['status']['serverStatus_lastCheck'] = time();
$statusInfo = new ServerStatus($config['server']['ip'], $config['server']['statusProtocolPort'], 1);
if ($statusInfo->isOnline()) {
$config['status']['serverStatus_online'] = 1;
$config['status']['serverStatus_players'] = $statusInfo->getPlayersCount();
$config['status']['serverStatus_playersMax'] = $statusInfo->getPlayersMaxCount();
$h = floor($statusInfo->getUptime() / 3600);
$m = floor(($statusInfo->getUptime() - $h * 3600) / 60);
$config['status']['serverStatus_uptime'] = $h . 'h ' . $m . 'm';
$config['status']['serverStatus_monsters'] = $statusInfo->getMonsters();
} else {
$config['status']['serverStatus_online'] = 0;
$config['status']['serverStatus_players'] = 0;
$config['status']['serverStatus_playersMax'] = 0;
}
$file = fopen("cache/DONT_EDIT_serverstatus.txt", "w");
$file_data = '';
foreach ($config['status'] as $param => $data) {
$file_data .= $param . ' = "' . str_replace('"', '', $data) . '"
';
}
rewind($file);
fwrite($file, $file_data);
fclose($file);
}
Last edited: