<?PHP
require('sfb.php'); 
$link=intval($_GET[link]);
$row=mysql_fetch_assoc(mysql_query("SELECT * FROM tb_statlinks WHERE id='$link' and balance >= price"));
if ($row['id'] == '') {
    exit();
} else
if ($row['balance'] < $row['price']) {
	exit();
} else {
	mysql_query("UPDATE tb_statlinks set views = views + 1, balance = balance - '$advstatlink' WHERE id = '$link' and balance >= price") or die(mysql_error());
	mysql_query("INSERT INTO tb_viruchka (ident, money, month, year) VALUES (4, '$advstatlink', '" . date('m', time()) . "', '" . date('Y', time()) . "')");
}
?>
<meta http-equiv="refresh" content="0; url=<?=$row['url']?>" />