<?PHP
session_start();
# Константа для Include
define("beerman", true);
require('sfb.php');
$ad = intval($_SESSION["ad"]);
$active=0;
$user = (isset($_SESSION["username"])) ? strip_tags(stripslashes($_SESSION["username"])) : NULL; 
$qwe = (isset($_GET["view"])) ? strip_tags(stripslashes($_GET["view"])) : NULL;
if($qwe != "ok"){
$t = time();
$t = $t+$_SESSION["timer"];
$_SESSION["endtime"] = intval($t);
}
if(mysql_result(mysql_query("SELECT `many` FROM `seo_paymails` WHERE `id`='$ad'"),0)==0 and mysql_num_rows(mysql_query("SELECT `id` FROM `seo_paymailsviews` WHERE `ident`='$ad' AND `fromid`= '".$_SESSION["iduser"]."'"))!=0){
?> <font color=red>Рекламодатель запретил повторный просмотр письма! </font><?
exit; 
}
?>

<script language=javascript>
if(self==parent) self.window.location='readmails.php';
</script>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<style type="text/css">
a, a:link, a:visited { color: #057fac; text-decoration: none; font-family: Verdana; font-size: 13px; }
a:hover {color: #f00; text-decoration: none; font-family: Verdana; font-size: 13px; }
#tbl {
background: none repeat scroll 0 0 #6d74a4;
padding: 5px;
width: 100%;
}
</style>
</head>
<body>

<?PHP if($active!='1'){ ?>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td style="background:#ffffff;" height="60%" valign="top">
<!--контент-->
<table height="58" id="tbl" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td style="font-family: Verdana;font-size: 13px;" width="350px" rowspan="2" valign=center>
<?PHP if($qwe!="ok"){ ?>
<script type="text/javascript">
function timer(){
var obj=document.getElementById('sfbtimer');
obj.innerHTML--;
if(obj.innerHTML==0){
location.replace("vlsmail.php?view=ok");
setTimeout(function(){},1000);}
else{setTimeout(timer,1000);}
}
setTimeout(timer,1000);
</script>
<noscript><meta http-equiv="refresh" content="<?=$_SESSION["timer"]?>; url=vlsmail.php?view=ok"></noscript>

<span class="tim">Пожалуйста ждите <span style="color:#ff0000" id="sfbtimer"><?=$_SESSION["timer"] ?></span> секунд...</span><?
}else{
include('successmail.php');
}
}else{
?>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td height="60%" valign="top">
<!--контент-->
<table id="tbl" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td style="font-family: Verdana;font-size: 13px;" width="350px" rowspan="2" valign=center>
<?PHP if($qwe != 'ok'){ ?>
<script type="text/javascript">
var b = false;
var last = 0;
function t() {
var c = document.getElementById('time');
if (typeof c == "undefined") return;
var t = parseInt(c.innerHTML);
last = stime();
if (t > 0) {
if (b == true) {
setTimeout('t()', 1000);
return;
}--t;
setTimeout('t()', 1000);
} else {
location.replace("vlsmail.php?view=ok");
}
c.innerHTML = t;
}
function stime() {
var d = new Date();
return d.getTime();
}
function w_obj() {
var wobj, i;
for (i = 0; i < 10; ++i) {
wobj = self.parent;
if ((wobj && !(wobj === self)) && (wobj.frames.length != 0)) {
wobj = self.parent;
}
}
return wobj;
}
var w;
if (navigator.appName == "Microsoft Internet Explorer") w = w_obj();
else w = top;
setTimeout('t()', 1000);
w.onblur = function() {
b = true;
}
w.onfocus = function() {
b = false;
}
w.onmousemove = function() {
b = false;
if (last > 0 && last < stime() - 1500) setTimeout('t()', 1000);
}
</script>
<span class="tim">Пожалуйста ждите <span id="time"><?=$_SESSION["timer"] ?></span> секунд...</span> 
<? }else{
include('successmail.php');
}
}
?>
</td>
<td align="right" style="padding:0 30px 17px 0;"><? include('inc/rotator.php'); ?></td>
</tr></table>
</td></tr></table>

</body>
</html>