ok now i have quite a bit of errors...
here is my code:
view_server.php: ERROR = it always says offline
<?php
include('core/init.inc.php');
$server_info = fetch_server_info($_GET['id']);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
table { width: 765px; border-collapse: collapse; background: #fff; }
td, th { padding: 4px; border: solid 1px #444; }
.online { background: #090; }
.offline { background: #900; }
a { color: white; }
</style>
<title><?php echo $server_info['name']; ?>'s Status</title>
</head>
<body>
<body background="ext/images/background.jpg">
<center>
<?php
if (fetch_user_rank() == 1) {
// give permission
echo '<a href="index.php"><img src="ext/images/home.jpg" width="93" height="27" alt=""></a><a href="admin.php"><img src="ext/images/admin.jpg" width="94" height="27" alt=""></a><a href="user_list.php"><img src="ext/images/members.jpg" width="134" height="27" alt=""></a><a href="status.php"><img src="ext/images/serverstatus.jpg" width="220" height="27" alt=""></a><a href="file_list.php"><img src="ext/images/files.jpg" width="76" height="27" alt=""></a><a href="edit_profile.php"><img src="ext/images/editprofile.jpg" width="176" height="27" alt=""></a><a href="logout.php"><img src="ext/images/logout.jpg" width="123" height="27" alt=""></a>';
} else {
//redirect them
echo '<a href="index.php"><img src="ext/images/home.jpg" width="93" height="27" alt=""></a><a href="user_list.php"><img src="ext/images/members.jpg" width="134" height="27" alt=""></a><a href="status.php"><img src="ext/images/serverstatus.jpg" width="220" height="27" alt=""></a><a href="file_list.php"><img src="ext/images/files.jpg" width="76" height="27" alt=""></a><a href="edit_profile.php"><img src="ext/images/editprofile.jpg" width="176" height="27" alt=""></a><a href="logout.php"><img src="ext/images/logout.jpg" width="123" height="27" alt=""></a>';
}
?>
</center>
<center>
<?php
if ($server_info === false){
echo '<br /><br /><br /><table><th><font color="red">The server status page you requested does not exist!</font></th></table>';
} else {
header("refresh:30;");
echo '<br /><font color="white">This page refreshes in about 30 secs.</font><br /><br />';
?>
</center>
<center>
<table>
<thead>
<tr>
<th>Server Owner</th>
<th>Server Type</th>
<th>Server Name</th>
<th>Server IP</th>
<th>Server Port</th>
<th>Server Status</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center"><?php echo $server_info['owner']; ?></td>
<td align="center"><?php echo $server_info['type']; ?></td>
<td align="center"><?php echo $server_info['name']; ?></td>
<td align="center"><?php echo $server_info['ip']; ?></td>
<td align="center"><?php echo $server_info['port']; ?></td>
<td align="center" class="<?php echo ($online) ? 'online' : 'offline'; ?>"><?php echo ($online) ? 'Online' : 'Offline'; ?></td>
</tr>
<tr>
<td align="center" colspan="6"><?php echo $server_info['about']; ?></td>
</tr>
<?php
}
?>
</tbody>
</table></center>
</body>
</html>
status.php: ERROR = always says online
<?php
include('core/init.inc.php');
$page = (isset($_GET['page'])) ? (int)$_GET['page'] : 1;
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
table { width: 600px; border-collapse: collapse; background: #fff; }
td, th { padding: 4px; border: solid 1px #444; }
.online { background: #090; }
.offline { background: #900; }
a { color: white; }
</style>
<title>Server Status</title>
</head>
<body background="ext/images/background.jpg">
<center>
<?php
if (fetch_user_rank() == 1) {
// give permission
echo '<a href="index.php"><img src="ext/images/home.jpg" width="93" height="27" alt=""></a><a href="admin.php"><img src="ext/images/admin.jpg" width="94" height="27" alt=""></a><a href="user_list.php"><img src="ext/images/members.jpg" width="134" height="27" alt=""></a><a href="status.php"><img src="ext/images/serverstatus.jpg" width="220" height="27" alt=""></a><a href="file_list.php"><img src="ext/images/files.jpg" width="76" height="27" alt=""></a><a href="edit_profile.php"><img src="ext/images/editprofile.jpg" width="176" height="27" alt=""></a><a href="logout.php"><img src="ext/images/logout.jpg" width="123" height="27" alt=""></a>';
} else {
//redirect them
echo '<a href="index.php"><img src="ext/images/home.jpg" width="93" height="27" alt=""></a><a href="user_list.php"><img src="ext/images/members.jpg" width="134" height="27" alt=""></a><a href="status.php"><img src="ext/images/serverstatus.jpg" width="220" height="27" alt=""></a><a href="file_list.php"><img src="ext/images/files.jpg" width="76" height="27" alt=""></a><a href="edit_profile.php"><img src="ext/images/editprofile.jpg" width="176" height="27" alt=""></a><a href="logout.php"><img src="ext/images/logout.jpg" width="123" height="27" alt=""></a>';
}
?><br />
<br />
<?php
echo '<p><font color="white">Do you want to <a href="add_server.php">Make a Server Status Page?</a></font></p>';
?>
</center><br />
<center><table>
<thead>
<tr>
<th>Server Owner</th>
<th>Server Name</th>
<th>Server Version</th>
<th>Server Type</th>
<th>Server Status</th>
</tr>
</thead>
<tbody>
<?php
foreach (fetch_servers($page, 5) as $server){
$online = server_online($server[0], $server[1]);
?>
<tr>
<td align="center"><?php echo $server['owner']; ?></td>
<td align="center"><a href="view_server.php?id=<?php echo $server['id']; ?>"><font color="black"><?php echo $server['name']; ?></font></a></td>
<td align="center"><?php echo $server['version']; ?></td>
<td align="center"><?php echo $server['type']; ?></td>
<td align="center" class="<?php echo ($online) ? 'online' : 'offline'; ?>"><?php echo ($online) ? 'Online' : 'Offline'; ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
<br />
<center>
<?php
$total_pages = ceil(fetch_total_servers() / 5);
for ($i = 1; $i <= $total_pages; ++$i){
echo " <a href=\"?page={$i}\">{$i}</a> ";
}
?>
</center></center>
</body>
</html>
server.inc.php: Error = not sure i think it has to do with server_online <= that function && function fetch_server_info()
<?php
// checks if server is online
function server_online($server, $port){
fsockopen($server, $port, $errno, $errstr, 0.1);
return ($errno === 0);
}
function fetch_servers($page, $per_page){
$start = (int)($page - 1) * $per_page;
$per_page = (int)$per_page;
$result = mysql_query("SELECT `server_id` AS `id`, `server_owner` AS `owner`, `server_type` AS `type`, `server_version` AS `version`, `server_name` AS `name`, `server_ip` AS `ip`, `server_port` AS `port` FROM `server_status` LIMIT {$start}, {$per_page}");
$servers = array();
while (($row = mysql_fetch_assoc($result)) !== false){
$servers[] = $row;
}
return $servers;
}
function fetch_total_servers(){
$result = mysql_query('SELECT COUNT(`server_id`) FROM `server_status`');
return mysql_result($result, 0);
}
function server_name_exists($server_name){
$server_name = mysql_real_escape_string($server_name);
$total = mysql_query("SELECT COUNT(`server_id`) FROM `server_status` WHERE `server_name` = '{$server_name}'");
return (mysql_result($total, 0) == '1') ? true : false;
}
function server_ip_exists($server_ip){
$server_ip = mysql_real_escape_string($server_ip);
$total = mysql_query("SELECT COUNT(`server_id`) FROM `server_status` WHERE `server_ip` = '{$server_ip}'");
return (mysql_result($total, 0) == '1') ? true : false;
}
function add_server($server_owner, $server_type, $server_version, $server_name, $server_ip, $server_port, $server_about){
$server_owner = $_POST['server_owner'];
$server_type = $_POST['server_type'];
$server_version = $_POST['server_version'];
$server_name = $_POST['server_name'];
$server_ip = $_POST['server_ip'];
$server_port = $_POST['server_port'];
$server_about = $_POST['server_about'];
$insert = 'INSERT into server_status(server_owner, server_type, server_version, server_name, server_ip, server_port, server_about) VALUES ("'. $server_owner .'", "'. $server_type .'", "'. $server_version .'", "'. $server_name .'", "'. $server_ip .'", "'. $server_port .'", "'. $server_about .'")';
mysql_query($insert);
}
function fetch_server_info($id){
$id = (int)$id;
$sql = "SELECT
`server_id` AS `id`,
`server_owner` AS `owner`,
`server_type` AS `type`,
`server_version` AS `version`,
`server_name` AS `name`,
`server_ip` AS `ip`,
`server_port` AS `port`,
`server_about` AS `about`
FROM `server_status`
WHERE `server_id` = {$id}";
$result = mysql_query($sql);
return $result;
}
?>
PS
i was able to make add_server.php to work the ones above i need help with. :\