<? include('checkcookie.php'); ?>
<h3>Заказы ссылок</h3>
<br>

<?
if (isset($_GET["id"]))
{

$id=$_GET["id"];
$option=$_GET["option"];
$pemail=$_POST["pemail"];
$plan=$_POST["plan"];
$url=$_POST["url"];
$description=$_POST["description"];
$bold=$_POST["bold"];
$highlight=$_POST["highlight"];
$fechainicia=time();
$timer=$_POST["timer"];
$dopsec=$_POST["dopsec"];
$vip=$_POST["vip"];

if ($option=="approve"){

    $query = "INSERT INTO tb_ads1 (fechainicia, paypalemail, plan, url, description, tipo, highlight, timer, dopsec, vip) VALUES('$fechainicia','$pemail','$plan','$url','$description','ads','$highlight', '$timer', '$dopsec','$vip')";
    mysql_query($query) or die(mysql_error());

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

	$t=date("d.m.Y", time());
	$res=mysql_query("select count(id) as kol from tb_adsdate1 where data='$t'");
	$res=mysql_Fetch_array($res);
	if($res["kol"]>0)
	{
		mysql_query("update tb_adsdate1 set kolvo=kolvo+1 where data='$t'");
	}else{
		mysql_query("insert into tb_adsdate1 (data,kolvo) values ('$t','1')");
	}

    echo "<font color=\"green\"><b>Реклама добавлена.</b></font><br><br>";
}

if ($option=="deny"){

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

    echo "<font color=\"#cc0000\"><b>Реклама удалена.</b></font><br><br>";
}


}
?>

<table>
	<tr>
		<th>№</th>
		<th>WMID</th>
		<th>Визитов</th>
		<th>Таймер</th>
		<th>URL</th>
		<th>Описание</th>
		<th>Выделение</th>
		<th>Доп. защита</th>
		<th>Размещение в VIP блоке</th>
		<th></th>
		<th></th>
	</tr>
<?
$tabla = mysql_query("SELECT * FROM tb_advertisers where tipo!='convert' ORDER BY id ASC");
while ($registro = mysql_fetch_array($tabla)) {

echo "
<tr>
<td>". $registro["id"] ."</td>
<td>". $registro["pemail"] ."</td>
<td>". $registro["plan"] ."</td>
<td>". $registro["timer"] ."</td>
<td><a href=\"". $registro["url"] ."\" target=\"_blank\">". $registro["url"] ."</a></td>
<td>". $registro["description"] ."</td>
<td>". $registro["highlight"] ."</td><td>"; 
if($registro["dopsec"]!='0') { echo "Да"; }else{ echo "Нет"; }
echo "</td><td>";
if($registro["vip"]!='0') { echo "Да"; }else{ echo "Нет"; }
echo "</td><td>";
?>
<form method="post" action="adminmain.php?p=viewreklreq1&id=<?= $registro["id"] ?>&option=approve">
<input type="hidden" name="pemail" value="<?= $registro["pemail"] ?>">
<input type="hidden" name="plan" value="<?= $registro["plan"] ?>">
<input type="hidden" name="timer" value="<?= $registro["timer"] ?>">
<input type="hidden" name="url" value="<?= $registro["url"] ?>">
<input type="hidden" name="description" value="<?= $registro["description"] ?>">
<input type="hidden" name="highlight" value="<?= $registro["highlight"] ?>">
<input type="hidden" name="dopsec" value="<?= $registro["dopsec"] ?>">
<input type="hidden" name="vip" value="<?= $registro["vip"] ?>">
<input type="submit" value="добавить" class="button">
</form>
</td><td>
<form method="post" action="adminmain.php?p=viewreklreq1&id=<?= $registro["id"] ?>&option=deny">
<input type="submit" value="удалить" class="button">
</form>
</td>
</tr>
<?
} 
?>
</table>