<? include('checkcookie.php'); ?>
<h3>Просмотр и удаление нарушителей.</h3>
<br>
<center>
<?
if(isset($_POST["id"]))
{
	$id=$_POST["id"];
	$wmid=$_POST["wmid"];
	$addlogin=$_POST["addlogin"];
		$naru=$_POST["naru"];

	mysql_query("UPDATE tb_nar SET wmid='$wmid', login='$addlogin', naru='$naru' where id='$id'");

	echo "<font color=\"green\"><b>Готово.</b></font><br><br>";
}

if(isset($_GET["id"]))
{
	$id=$_GET["id"];
	if ($_GET["option"]=="edit")
	{
		$tablae = mysql_query("SELECT * FROM tb_nar where id='$id'"); 
		while ($registroe = mysql_fetch_array($tablae))
		{ 
			?>
			<form method="post" action="adminmain.php?p=viewblacklist">
				WMID <input type="text" name="wmid" value="<?= $registroe["wmid"] ?>"><br>
				Логин <br><input type="text" name="addlogin" value="<?= $registroe["login"] ?>"><br>
				Нарушение <input type="text" name="naru" value="<?= $registroe["naru"] ?>"><br>
				<input type="hidden" value="<?=$id ?>" name="id">
				<input type="submit" value="сохранить" class="button">
			</form>
			<?
		}
	}
	if ($_GET["option"]=="delete")
	{
		$id=$_GET["id"];
		mysql_query("DELETE FROM tb_nar WHERE id='$id'");

		echo "<font color=\"#cc0000\"><b>Сообщение удалено.</b></font><br><br>";
	}
}
?>

<br>
<table>
	<tr>
		<th>№</th>
		<th>WMID</th>
		<th>Логин</th>
		<th>Нарушение</th>
		<th></th>

	</tr>
	<?

	$sql="SELECT * FROM tb_nar order by id desc";

	$tabla = mysql_query($sql); 
	while ($registro = mysql_fetch_array($tabla))
	{
		?>
		<tr>
			<td><?=$registro["id"] ?></td>
			<td><?=$registro["wmid"] ?></td>
			<td><?=$registro["login"] ?></td>
            <td><?=$registro["naru"] ?></td>
			<td>
				<form method="post" action="adminmain.php?p=viewblacklist&id=<?= $registro["id"] ?>&option=delete">
				<input type="submit" value="Удалить" class="button">
				</form>
			</td>
		</tr>
		<?
	} 
	?>
</table>
</center>