<?php
if (!defined('IN_HK') || !IN_HK)
{
    exit;
}

if (!HK_LOGGED_IN || !$users->hasFuse(USER_ID, 'fuse_housekeeping_moderation'))
{
    exit;
}

$name = '';

if (isset($_POST['user'])) { $name = filter($_POST['user']); }
require_once "top.php";            

echo("<h1>User Lookup</h1>
<br /><p>This tool can be used for looking up and editing a users rank, credits, pixels, motto or e-mail.</p>");
echo '<br />
<form method="post">
Username:<br />
<input type="text" name="user"><Br />
<input type="submit" value="Lookup">
</form>';
if (isset($name))
{
if (!$_POST['update'])
{
$users = mysql_query("SELECT * from users where username = '$name'");
$user = mysql_fetch_array($users);
echo("<div align=\"center\"><form method=\"POST\">
<table width=\"100%\">
<tr>
<td align=\"right\" width=\"25%\">
Username
</td>
<td align=\"left\">
$user[username]
<input type=\"hidden\" name=\"username\"
value=\"$user[username]\">
</td>
</tr>
<td align=\"right\" width=\"25%\">
Account created on
</td>
<td align=\"left\">
$user[account_created]
</td>
</tr>
<td align=\"right\" width=\"25%\">
User was last online on
</td>
<td align=\"left\">
$user[last_online]
</td>
</tr>
<td align=\"right\" width=\"25%\">
Users IP
</td>
<td align=\"left\">
$user[ip_last]
</td>
</tr>
<tr>
<td align=\"right\" width=\"25%\">
Rank
</td>
<td align=\"left\">
<input type=\"text\" size=\"25\" maxlength=\"25\" name=\"rank\"
value=\"$user[rank]\"></td>
</tr>
<tr>
<td align=\"right\" width=\"25%\">
Credits
</td>
<td align=\"left\">
<input type=\"text\" size=\"25\" maxlength=\"25\" name=\"credits\"
value=\"$user[credits]\"></td>
</tr>
<tr>
<td align=\"right\" width=\"25%\">
E-Mail
</td>
<td align=\"left\">
<input size=\"25\" name=\"mail\" value=\"$user[mail]\"></td>
</tr>
<tr>
<td align=\"right\" width=\"25%\">
Motto
</td>
<td align=\"left\">
<input size=\"25\" name=\"motto\"  value=\"$user[motto]\"></td>
</tr>
<tr>
<td align=\"right\" width=\"25%\">
Pixels</td>
<td align=\"left\">
<input size=\"25\"  name=\"pixels\" value=\"$user[activity_points]\"></td>
</tr>
<tr>
<td align=\"center\">
</td>
<td align=\"left\">
<input type=\"submit\" name=\"update\" value=\"Update\"></td>
</tr>
</table>
</form>
</div>");
}
else
{
$username = htmlspecialchars($_POST['username']);
$motto = htmlspecialchars($_POST['motto']);
$mail = htmlspecialchars($_POST['mail']);
$credits = htmlspecialchars($_POST['credits']);
$rank = htmlspecialchars($_POST['rank']);
$pixels = htmlspecialchars($_POST['pixels']);
echo ("<br /><br />$username's profile has been updated.");
$update = @mysql_query("Update users set mail = '$mail', motto = '$motto',
credits = '$credits', rank = '$rank', activity_points = '$pixels' where username = '$username'");
}
}
require_once "bottom.php";
?>