<?PHP
session_start();
define("beerman", true);
require('funciones.php');
include('sfb.php');

error_reporting(E_ERROR | E_PARSE);

$ad=$_GET["ad"];
if(!ereg("^[0-9]{1,255}$", $ad))
{
	$ad=-1;
}
$ad=intval($ad);

$sql_count = mysql_query("SELECT `id` FROM `seo_paymails` WHERE `id`='$ad' AND `modered`='1' AND `balance`>price AND `paused`='0'") or die(mysql_error());

if (mysql_num_rows($sql_count) < 1){
echo $infsterr." Ссылка не существует ".$infederr;
exit();
}

$_SESSION["ad"] = $ad;
$res = mysql_query("SELECT `url`, `timer` FROM `seo_paymails` WHERE `id`='$ad'");
$res = mysql_fetch_array($res);

$urlsite = $res["url"];
$_SESSION["urlsite"] = $urlsite;
$_SESSION["timer"] = $res["timer"];


if($_SESSION["username"]==NULL){
?>
	<script type="text/javascript">
	location.replace("<?=$urlsite?>");
	</script>
	<noscript>
	<meta http-equiv="refresh" content="0; url=<?=$urlsite?>">
	</noscript>
	<?
}
?>

<html>
<head>
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="-1">
<title><?
function title($gg)
{
	$gg=str_ireplace('<span>','',$gg);
	$gg=str_ireplace('</span>','',$gg); 
	return $gg;
}
 echo title($sitename) ?> - Система Активной Рекламы</title>

<frameset rows="*,76" border="0">

<frame name="frmsite" src="<?=$urlsite ?>"><frame marginwidth="0" marginheight="0" border=0 frameborder=0 framespacing=0 name="frminfo" scrolling="no" noresize src="vlsmail.php">
</frameset>

</head>
</html>