server status

What did you do?
i just change my status to what you gave me.. then no ONLINE OR OFFLINE text appears
try this..

Code:
<?php if (!defined('FLUX_ROOT')) exit; ?><h2><?php echo htmlspecialchars(Flux::message('ServerStatusHeading')) ?></h2><p><?php echo htmlspecialchars(Flux::message('ServerStatusInfo')) ?></p><?php foreach ($serverStatus as $privServerName => $gameServers): ?><h3>Server Status for <?php echo htmlspecialchars($privServerName) ?></h3><table id="server_status">	<tr>		<td class="status"><?php echo htmlspecialchars(Flux::message('ServerStatusServerLabel')) ?></td>		<td class="status"><?php echo htmlspecialchars(Flux::message('ServerStatusLoginLabel')) ?></td>		<td class="status"><?php echo htmlspecialchars(Flux::message('ServerStatusCharLabel')) ?></td>		<td class="status"><?php echo htmlspecialchars(Flux::message('ServerStatusMapLabel')) ?></td>		<td class="status"><?php echo htmlspecialchars(Flux::message('ServerStatusOnlineLabel')) ?></td>	</tr>	<?php foreach ($gameServers as $serverName => $gameServer): ?>	<tr>		<th class="server"><?php echo htmlspecialchars($serverName) ?></th>		<td class="status"><font color="green">ONLINE</font></td>		<td class="status"><font color="green">ONLINE</font></td>		<td class="status"><font color="green">ONLINE</font></td>		<td class="status"><?php echo $gameServer['playersOnline'] ?></td>	</tr>	<?php endforeach ?></table><?php endforeach ?>
 
it this the right way to fix the problem? this will show server online ALL THE TIME even offline.  is there any other way to fix this?
default_sad.png


 
it this the right way to fix the problem? this will show server online ALL THE TIME even offline.  is there any other way to fix this?
default_sad.png
There is another way, however, you'll require some tweaks to pull it off.

I personally have separated the information in two files (one config, one navigation), however, you can merge it into one.

Alter the $host, $user, $pwd & $db variables as needed.

Here's the config file:

// Server Timedate_default_timezone_set('America/Chicago'); //Change your timezone to your server's timezone.$today = date("H:i", time());// Server configuration$host = "SERVER_IP";$user = "SQL_USER";$pwd = "SQL_PASS";$db = "SQL_DATABASE";// Login, Char & Map Server ports$login = 6900;$char = 6121;$map = 5121;//PHP Data Objects -> onlinePlayersCount & serverOnline// Players Online$server = new PDO("mysql:host={$host};dbname={$db}",$user,$pwd);$sql = "SELECT COUNT(*) AS players_online FROM main.char WHERE online > 0";$onlinePlayersCount = $server->query($sql)->fetchColumn();// Server Statusfunction getServerStatus() { //global $host,$login,$char,$map; $host = "SERVER_IP"; $login = 6900; $char = 6121; $map = 5121; $loginStatus = @fsockopen($host,$login,$errno,$errstr); $charStatus = @fsockopen($host,$char,$errno,$errstr); $mapStatus = @fsockopen($host,$map,$errno,$errstr); if($loginStatus == false || $charStatus == false || $mapStatus == false){ return false; }else{ fclose($loginStatus); fclose($charStatus); fclose($mapStatus); return true; }}$serverOnline = getServerStatus();?>
And here's my navigation file:

<?phprequire_once('serv_config.php');?><ul class="pull-right"> <li>Time: <?php echo $today; ?></li> <li><span>Players: <?php echo $onlinePlayersCount; ?></span></li> <li><span>Server: <span id="<?php if($serverOnline == true) { echo "server-online";} else {echo "server-offline";}?>"><?php if($serverOnline == true) {echo "Online";} else {echo "Offline";} ?></span></span></li></ul> <!-- pull-right -->
The CSS for the online/offline indicators (green&red):

.main-navigation #server-online { color: green;}.main-navigation #server-offline { color: red;}
All these tweaks I have applied to Herc's FluxCP with the emphaino theme. There's more CSS involved with this, however, it's not relevant for the code you wanted and just visual positioning etc.

Good luck.

 
Back
Top