Problems with server status page.
Posted: Mon Sep 23, 2013 8:22 am
Hello,
I was able to get this working perfectly on my localhost but soon as I upload it to my web server it does not work.
Does this only work on a localhost?
I have included all the php files.
Any help would be greatly appreciated.
Thanks
Alex
[syntax=php]
<?php
//checks if the given server is online.
function server_online($server, $port)
{
fsockopen($server, $port, $errno, $errstr, 0.1);
return($errno ===0);
}
?>
[/syntax]
[syntax=php]
<?php
$servers = array (
array('',''),
array('',''),
array('',''),
);
error_reporting(0);
include("/servers.inc.php");
?>
[/syntax]
[syntax=php]
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="content-type" content="text/html" />
<meta name="author" content="lolkittens" />
<title>Untitled 4</title>
<style type="text/css">
table {width: 600px: border-collapse: collapse; }
td, th {padding: 4px; border: solid1px #444;}
.online {background: #090;}
.offline {background: #900;}
</style>
</head>
<body>
<div id="server">
<table>
<tr>
<th>Server</th>
<th>Status</th>
</tr>
<tbody>
<?php
require('includes/init.inc.php');
foreach ($servers as $server){
$online = server_online($server[0], $server[1]);
?>
<tr>
<td><?php echo $server[0], ':', $server[1]; ?></td>
<td class="<?php echo ($online) ? 'online':'offline'?>"><?php echo ($online) ? 'Online':'Offline'; ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</body>
</html>
[/syntax]
I was able to get this working perfectly on my localhost but soon as I upload it to my web server it does not work.
Does this only work on a localhost?
I have included all the php files.
Any help would be greatly appreciated.
Thanks
Alex
[syntax=php]
<?php
//checks if the given server is online.
function server_online($server, $port)
{
fsockopen($server, $port, $errno, $errstr, 0.1);
return($errno ===0);
}
?>
[/syntax]
[syntax=php]
<?php
$servers = array (
array('',''),
array('',''),
array('',''),
);
error_reporting(0);
include("/servers.inc.php");
?>
[/syntax]
[syntax=php]
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="content-type" content="text/html" />
<meta name="author" content="lolkittens" />
<title>Untitled 4</title>
<style type="text/css">
table {width: 600px: border-collapse: collapse; }
td, th {padding: 4px; border: solid1px #444;}
.online {background: #090;}
.offline {background: #900;}
</style>
</head>
<body>
<div id="server">
<table>
<tr>
<th>Server</th>
<th>Status</th>
</tr>
<tbody>
<?php
require('includes/init.inc.php');
foreach ($servers as $server){
$online = server_online($server[0], $server[1]);
?>
<tr>
<td><?php echo $server[0], ':', $server[1]; ?></td>
<td class="<?php echo ($online) ? 'online':'offline'?>"><?php echo ($online) ? 'Online':'Offline'; ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</body>
</html>
[/syntax]