<?PHP
require_once($_SERVER['DOCUMENT_ROOT']."/config.php");
$link = intval($_GET["link"]);
$sql = mysql_query("SELECT `url` FROM `tb_advban` WHERE `id`='$link'") or die(mysql_error());
if(mysql_num_rows($sql) > 0){
$row = mysql_fetch_assoc($sql);
$url_go = $row["url"];
mysql_query("UPDATE `tb_advban` SET `views`=`views`+'1',`balance`=`balance`-`price` WHERE `id`='$link'") or die(mysql_error());

echo "<meta http-equiv='refresh' content='0; url=$url_go'>";
}else{
include($_SERVER['DOCUMENT_ROOT'].'/header.php');
if(!defined('beerman')) {exit();}
echo "<h1>Просмотр баннеров</h1>";
echo "$infstart Нет такой ссылки!$infend </fieldset>";
include($_SERVER['DOCUMENT_ROOT'].'/footer.php');
exit();
}
?>