<? include('checkcookie.php'); ?>
<h3>Заказы псевдодинамических ссылок</h3>
<br>

<?
if (isset($_GET["id"]))
{
	$id=$_GET["id"];
	$option=$_GET["option"];
	$urlsite=$_POST["urlsite"];
	$description=$_POST["description"];
	$wmid=$_POST["wmid"];
	$plan=$_POST["plan"];
	$t=time();
	
	
	if ($option=="approve")
	{
		$query = "INSERT INTO tb_psevdolinks (url,description,wmid,begindate,numdays) VALUES('$urlsite','$description','$wmid','$t','$plan')";
		mysql_query($query) or die(mysql_error());

		$queryz = "DELETE FROM tb_psevdoreq WHERE id='$id'";
		mysql_query($queryz) or die(mysql_error());


		echo "<font color=\"red\"><b>Псевдодинамическая ссылка добавлена.</b></font><br><br>";
	}

	if ($option=="deny")
	{
		$queryz = "DELETE FROM tb_psevdoreq WHERE id='$id'";
		mysql_query($queryz) or die(mysql_error());

		echo "<font color=\"#ff0000\"><b>Заказ ссылки удален.</b></font><br><br>";
	}
}
?>

<table width='100%' border='0' cellpadding='0' cellspacing='0'>
	<tr>
		<th>№</th>
		<th>WMID</th>
		<th>URL сайта</th>
		<th>Текст ссылки</th>
		<th>Тариф</th>
		<th></th>
		<th></th>
	</tr>
<?
$tabla = mysql_query("SELECT * FROM tb_psevdoreq ORDER BY id ASC");
while ($registro = mysql_fetch_array($tabla)) {

echo "
<tr>
<td>". $registro["id"] ."</td>
<td>". $registro["wmid"] ."</td>
<td><a href=\"". $registro["url"] ."\" target=\"_blank\">". $registro["url"] ."</a></td>
<td>". $registro["description"] ."</td>
<td>". $registro["plan"] ."</td>";
echo "<td>";
?>
<form method="post" action="adminmain.php?p=psevdoreq&id=<?= $registro["id"] ?>&option=approve">
<input type="hidden" name="urlsite" value="<?= $registro["url"] ?>">
<input type="hidden" name="description" value="<?= $registro["description"] ?>">
<input type="hidden" name="wmid" value="<?= $registro["wmid"] ?>">
<input type="hidden" name="plan" value="<?= $registro["plan"] ?>">
<input type="submit" value="Добавить" class="button">
</form>
</td><td>
<form method="post" action="adminmain.php?p=psevdoreq&id=<?= $registro["id"] ?>&option=deny">
<input type="submit" value="Удалить" class="button">
</form>
</td>
</tr>

<?

} 

?>
</table>