Elite Diviner
- Joined
- Feb 27, 2012
- Messages
- 446
- Reaction score
- 46
Hey guys, I started working on a server status script for fiesta. Basically the game uses services which broadcast to specific ports when they are running. My only question is, How does this look? So basically i was just wondering if this method is the right one to use and if there is any major flaws I should look into. I am not asking for any answers just hints to point me in the right direction.
PHP:
<?php
function check_port($port) {
$conn = @fsockopen($_SERVER['SERVER_ADDR'], $port, $errno, $errstr, 0.2);
if ($conn) {
fclose($conn);
return true;
}
}
function server_report() {
$report = array();
$svcs = array('9110'=>'World',
'9120'=>'Zone1',
'9122'=>'Zone2',
'9124'=>'Zone3',
'9010'=>'Login');
foreach ($svcs as $port=>$service) {
$report[$service] = check_port($port);
}
return $report;
}
$report = server_report();
echo
"<table>
<tr>
<td>Server</td>
<td>Status</td>
<tr>
<td>All Servers</td>
<td>"; echo $report['World']&$report['Zone1']&$report['Zone2']&$report['Zone3']&$report['Login'] ? 'Online' : 'Offline'; echo "</td>
</tr>
</table>";
?>