diff --git a/src/bf2sclone/template/server.php b/src/bf2sclone/template/server.php index f17b842..d410ca6 100644 --- a/src/bf2sclone/template/server.php +++ b/src/bf2sclone/template/server.php @@ -4,7 +4,7 @@ - ' . (isset($s['data']) ? esc_attr($s['data']['server']['hostname']) . ', ' : 'Unknown server, ') . esc_attr(TITLE) . ' + ' . ($s['data'] ? esc_attr($s['data']['server']['hostname']) : esc_attr($s['name'])) . ', ' . esc_attr(TITLE) . ' @@ -22,7 +22,7 @@
-

' . ($s['data'] ? esc_attr($s['data']['server']['hostname']) : '-') . '

+

' . ($s['data'] ? esc_attr($s['data']['server']['hostname']) : esc_attr($s['name'])) . '

@@ -50,7 +50,7 @@ Status - ' . ($s['data'] ? esc_attr($s['data']['server']['gamemode']) : '-') . ' + ' . ($s['data'] ? esc_attr($s['data']['server']['gamemode']) : 'OFFLINE') . ' Players ' . ($s['data'] ? esc_attr("{$s['data']['server']['numplayers']}/{$s['data']['server']['maxplayers']}") : '-') . ' diff --git a/src/bf2sclone/template/servers.php b/src/bf2sclone/template/servers.php index c963e75..2d6e5db 100644 --- a/src/bf2sclone/template/servers.php +++ b/src/bf2sclone/template/servers.php @@ -43,94 +43,113 @@ '; foreach($servers as $s) { - if (!$s['data']) { - continue; - } + // Show only online servers? + // if ($s['data'] === false) { + // continue; + // } + $template .= ' - - '; - - $serverLoad = $s['data']['server']['numplayers'] / $s['data']['server']['maxplayers']; - if ($serverLoad >= 0.66) { - $template .= 'High Load'; - } else if ($serverLoad >= 0.33) { - $template .= 'Medium Load'; + + '; + if ($s['data'] === false) { + $template .= ' +
+ OFF + + + + ' . esc_attr($s['name']) . ' + - + - + - + - + - + - + '; } else { - $template .= 'Low Load'; - } + $template .= '
'; + $serverLoad = $s['data']['server']['numplayers'] / $s['data']['server']['maxplayers']; + if ($serverLoad >= 0.66) { + $template .= 'High Load'; + } else if ($serverLoad >= 0.33) { + $template .= 'Medium Load'; + } else { + $template .= 'Low Load'; + } - if (preg_match('/^linux/', $s['data']['server']['bf2_os'])) { - $template .= 'Linux'; - } else { - $template .= 'Windows'; - } + if (preg_match('/^linux/', $s['data']['server']['bf2_os'])) { + $template .= 'Linux'; + } else { + $template .= 'Windows'; + } - if (preg_match('/-64$/', $s['data']['server']['bf2_os'])) { - $template .= '64-bit'; - } else { - $template .= 'Not 64-bit'; - } - - if (file_exists(ROOT . "/game-images/mods/{$s['data']['server']['gamevariant']}/mod_icon.png")) { - $mod = esc_attr($s['data']['server']['gamevariant']); - $template .= '' . esc_attr($mod) . ''; - } else { - $template .= 'unknown_mod'; - } + if (preg_match('/-64$/', $s['data']['server']['bf2_os'])) { + $template .= '64-bit'; + } else { + $template .= 'Not 64-bit'; + } + + if (file_exists(ROOT . "/game-images/mods/{$s['data']['server']['gamevariant']}/mod_icon.png")) { + $mod = esc_attr($s['data']['server']['gamevariant']); + $template .= '' . esc_attr($mod) . ''; + } else { + $template .= 'unknown_mod'; + } - if ($s['data']['server']['bf2_ranked']) { - $template .= 'Ranked'; - } else { - $template .= 'Unranked'; - } + if ($s['data']['server']['bf2_ranked']) { + $template .= 'Ranked'; + } else { + $template .= 'Unranked'; + } - if ($s['data']['server']['bf2_autorec']) { - $template .= 'BattleRecorder On'; - } else { - $template .= 'BattleRecorder Off'; - } + if ($s['data']['server']['bf2_autorec']) { + $template .= 'BattleRecorder On'; + } else { + $template .= 'BattleRecorder Off'; + } - if ($s['data']['server']['bf2_voip']) { - $template .= 'BattleCommo On'; - } else { - $template .= 'BattleCommo Off'; - } + if ($s['data']['server']['bf2_voip']) { + $template .= 'BattleCommo On'; + } else { + $template .= 'BattleCommo Off'; + } - if ($s['data']['server']['bf2_anticheat']) { - $template .= 'Punkbuster On'; - } else { - $template .= 'Punkbuster Off'; - } - - if ($s['data']['server']['bf2_pure']) { - $template .= 'Pure'; - } else { - $template .= 'Not Pure'; - } - - if ($s['data']['server']['password']) { - $template .= 'PasswordEnabled'; - } else { - $template .= 'No Password'; - } + if ($s['data']['server']['bf2_anticheat']) { + $template .= 'Punkbuster On'; + } else { + $template .= 'Punkbuster Off'; + } + + if ($s['data']['server']['bf2_pure']) { + $template .= 'Pure'; + } else { + $template .= 'Not Pure'; + } + + if ($s['data']['server']['password']) { + $template .= 'PasswordEnabled'; + } else { + $template .= 'No Password'; + } - $map = str_replace(' ', '_', strtolower($s['data']['server']['mapname'])); - // devil's Perch Fix - $map = str_replace('\'', '', $map); - $mapUrl = file_exists(ROOT . "/game-images/levels/$map.png") ? "$ROOT/game-images/levels/$map.png" : "$ROOT/game-images/levels/default.png"; - $template .= ' - - ' . esc_attr($s['data']['server']['hostname']) . ' - ' . esc_attr("{$s['data']['server']['numplayers']}/{$s['data']['server']['maxplayers']}"). ' - - ' . esc_attr($map) . '' . - ' ' . esc_attr($s['data']['server']['mapname']) . ' - - ' . esc_attr($s['data']['server']['bf2_mapsize']) . ' - ' . (preg_match('/gpm_coop/i', $s['data']['server']['gametype']) ? 'Co-op' : 'Conquest') . ' - ' . esc_attr($s['data']['server']['gamevariant']). ' - ' . esc_attr(preg_replace('/^(\d+\.\d+).*$/', '$1', $s['data']['server']['gamever'])). ' - '; + $map = str_replace(' ', '_', strtolower($s['data']['server']['mapname'])); + // devil's Perch Fix + $map = str_replace('\'', '', $map); + $mapUrl = file_exists(ROOT . "/game-images/levels/$map.png") ? "$ROOT/game-images/levels/$map.png" : "$ROOT/game-images/levels/default.png"; + $template .= ' + + ' . esc_attr($s['data']['server']['hostname']) . ' + ' . esc_attr("{$s['data']['server']['numplayers']}/{$s['data']['server']['maxplayers']}"). ' + + ' . esc_attr($map) . '' . + ' ' . esc_attr($s['data']['server']['mapname']) . ' + + ' . esc_attr($s['data']['server']['bf2_mapsize']) . ' + ' . (preg_match('/gpm_coop/i', $s['data']['server']['gametype']) ? 'Co-op' : 'Conquest') . ' + ' . esc_attr($s['data']['server']['gamevariant']). ' + ' . esc_attr(preg_replace('/^(\d+\.\d+).*$/', '$1', $s['data']['server']['gamever'])). ' + '; + } } $template .= '