<?
require_once("../classes/network.php");
require_once("../classes/user.php");
session_start(); //Start session
$user = new User();
$network = new Network();
if (!$user->IsAdmin())
header("profile.php");
else
{
if (IsSet($id2remove))
{
$user->RemoveUser($id2remove);
}
}
// shows a menu
function ShowMenu($user,$user_id)
{
if ($user->IsAdmin())
{
$name = $user->GetUserName($user_id);
print "\n\t\t\t\t<td height=19>[ <a href=selnodes.php?id=id0>your nodes</a> ]</td>\n";
if ($user_id == 0)
{
print "\t\t\t\t<td height=19>[ <a href=profile.php>your details</a> ]</td>\n";
}
else
{
print "\t\t\t\t<td height=19>[ <a href=profile.php?id=0>your details</a> ]</td>\n";
}
print "<td>[ <a href=prefs.php>preferences</a> ]</td>";
print "\t\t\t</tr>\n\t\t</table>\n\t\t<table align=center>\n\t\t\t<tr>\n";
if ($user_id != 0)
{
print "\t\t\t\t<td height=19>[ <a href=selnodes.php?id=id$user_id>$name's nodes</a> ]</td>\n";
print "\t\t\t\t<td height=19>[ $name's details ]</td>\n";
}
print "\t\t\t\t<td height=19>[ users ]</td>\n";
}
else
{
print "\n\t\t\t\t<td height=19>[ <a href=profile.php>your details</a> ]</td>\n";
print "\t\t\t\t<td height=19>[ <a href=selnodes.php?id=id0>your nodes</a> ]</td>\n";
}
}
function GenerateUserList()
{
$user = new User();
$resID = $user->GetAllUsers();
//This variable is for shifting the color for each row in the table.
$colorshift = 0;
$bgcolor = array("\"#EEEEEE\"", "\"#E6E6E6\"");
if ($resID)
{
while(List($user_id, $username, $email, $type) = $user->FetchRow($resID))
{
// Set background color of the row
print "<tr bgcolor=$bgcolor[$colorshift]>\n";
$colorshift = 1 - $colorshift;
print "<td><a href=\"profile.php?id=$user_id\">$username</a></font></td>\n";
print "<td><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\" color=\"#000000\">$email</font></td>\n";
print "<td><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\" color=\"#000000\">$type</font></td>\n";
if ($user_id == $user->GetUserID())
print "<td align=\"right\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\" color=\"#000000\">-</font></td>\n";
else
print "<td align=\"right\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\" color=\"#000000\"><a href=\"javascript: RemoveUser($user_id);\"> delete</a></font></td>\n";
}
}
}
?>
<html>
<head>
<link href="css/style1.css" rel="styleSheet" type="text/css">
<script>
function RemoveUser(user_id)
{
if (confirm("Are you sure you want to remove this user?"))
document.location = "allusers.php?id2remove=" + user_id;
}
</script>
</head>
<body>
<? include("menuinclude.php");?>
<br><br>
<table align="center">
<tr>
<? ShowMenu($user,$user_id) ?>
</tr>
</table>
<br>
<br>
<!-- background table -->
<table width="90%" align="center" border="0" cellspacing="2" cellpadding="0" bgcolor="#000000">
<tr>
<td>
<!-- gui table -->
<table width="100%" border="0" cellspacing="0" cellpadding="2">
<!-- title row -->
<tr>
<td bgcolor="#515173" colspan="4">
<font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#FFFFFF"><b>All WaveWatchers...</b></font>
</td>
</tr>
<!-- user lines -->
<tr bgcolor="#c0c0c0">
<!--<td><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000"><b>UserID</b></font></td>-->
<td><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000"><b>Username</b></font></td>
<td><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000"><b>Email</b></font></td>
<td><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000"><b>Type</b></font></td>
<td align="right"><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000"><b>Delete user</b></font></td>
</tr>
<? GenerateUserList(); ?>
</table>
</td>
</tr>
</table>
<br><br><br><center>[ <a href=register.php>create a new user</a> ]
</body>
</html>