<? include('checkcookie.php'); ?>
<h3>Статические ссылки,ожидающие модерации</h3>
<br>
<?
if(isset($_POST["del"])){
$id=intval($_POST["id"]);
mysql_query("DELETE FROM `tb_statlinks` WHERE `id`='$id'");
echo "<div style='text-align:center;margin-top: -10px;padding: 10px;'>Ссылка удалена!</div>";
}
 if(isset($_POST["ok"])){
$id=intval($_POST["id"]);
mysql_query("UPDATE tb_statlinks SET modered='1' where id='$id'");
echo "<div style='text-align:center;margin-top: -10px;padding: 10px;'>Ссылка одобрена!</div>";
}
if(isset($_POST["no"])){
$id=intval($_POST["id"]);
if(isset($_POST["reas"])){
$reas=$_POST["reas"];
mysql_query("update tb_statlinks set modered='2',reas='$reas' where id='$id'");
echo "<div style='text-align:center;margin-top: -10px;padding: 10px;'>Ссылка отклонена</div>";
}else{
?>
<center><form action='' method='post'>
<input type='hidden' name='no' value='no'>
<input type='hidden' name='id' value='<?=$id ?>'>
<input type='text' name='reas' value='введите причину'>
<input type='submit' value='подтвердить отклонение'>
</form>
<?
}
}
?>
<style type="text/css">
A {text-decoration:none;} 
A:hover {text-decoration:none;color:red;} 
  </style>
<center><a href="adminmain.php?p=statlinkreq&deleted=0"><b style="padding:7px 10px; border:1px solid #7AB257;border-radius:5px;color:#7AB257;">Модерация</b></a> <a href="adminmain.php?p=statlinkreq&deleted=1"><b style="padding:7px 10px; border:1px solid #FF0000;border-radius:5px;color:#FF0000;">Удаление</b></a></center><br>
<table class="adn">
<tr class="lineb">
		<td width="50">№</th>
		<td>URL & DESC</td>
		<td>Текст</td>
		<td>Разместил</td>
		<td></td>
		<td></td>
	</tr>
<?
if(isset($_GET["deleted"]) && intval($_GET["deleted"]) == 1) {
$zapros = "`modered`='1'";
}else{
$zapros = "`modered`='0'";
}
$tabla = mysql_query("SELECT * FROM tb_statlinks where modered='0' ORDER BY id ASC");
while ($registro = mysql_fetch_array($tabla)) {
$row=mysql_fetch_assoc(mysql_query("SELECT username from b_users where id='".$registro["fromus"]."'"));
$uname = $row["username"];
echo "<tr class='liney ell'>
<td align=center>". $registro["id"] ."</td>
<td align=center><a href='".$registro["url"]."' target='_blank'>".$registro["description"]."</a></td>
<td align=center>".$registro["texto"]."</td>
<td align=center>".$registro["fromus"]." | $uname</a></td>";

if(isset($_GET["deleted"]) && intval($_GET["deleted"]) == 1) {
echo "<td colspan='2' align='center'>";
echo "<form action='' method='post'>";
echo "<input type='hidden' name='id' value='".$registro["id"]."'>";
echo "<input type='submit' name='del' value='Удалить'>";
echo "</form></td>";
}else{?>
<td align=center>
<form action='' method='post'>
<input type='hidden' name='id' value='<?=$registro["id"] ?>'>
<input type='submit' name='ok' value='Одобрить'>
</form>
</td><td align=center>
<form action='' method='post'>
<input type='hidden' name='id' value='<?=$registro["id"] ?>'>
<input type='submit' name='no' value='Отклонить'>
</form>
</td>
</tr>
<?
}
}
?>
</table>