<?php
//session_start();
$id = intval($pg->params[1]);
if (!isset($_SESSION['uid'])) { exit(); }
$nums = $db->query("SELECT * FROM db_surfv WHERE id = '".$id."' and balance >= price_click and status = '1' LIMIT 1")->numRows();
if ($nums >= 1){
$list = $db->query("SELECT * FROM db_surfv WHERE id = '$id'")->fetchArray();
$price = $list['price_click'];
$_SESSION['view']['cnt'] = md5(session_id().$list['uid'].$list['id']);
$_SESSION['view']['id'] = $list['id'];
$_SESSION['view']['timer'] = $list['timer'];
$_SESSION['view']['timestart'] = time();
$opt = array('title' => false,'description' => false);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="robots" content="none" />
<title>Просмотр: <?=$list['title'];?></title>
<link href="https://fonts.googleapis.com/css?family=Play" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Pangolin" rel="stylesheet">
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://www.youtube.com/iframe_api"></script>
<link href="/assets/css/framev.css?v2" rel="stylesheet" type="text/css">
<link href="/assets/css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link rel="icon" type="image/png" href="/assets/images/favicon.png" sizes="32x32">
<link rel="apple-touch-icon" href="/assets/images/favicon.png">
</head>
<body>
<style type="text/css">
.video {
height: 0;
position: relative;
padding-bottom: 56.25%;
}
.video iframe {
position: absolute;
width: 100%;min-height: 77%;
}
</style>
<script>
var interval = '',
played = 0,
info_ch = true,
fullyPlayed = false,
player, playing = false,
cnt = '<?=$_SESSION['view']['cnt'];?>';
function onYouTubeIframeAPIReady() {
player = new YT.Player('ytPlayer', {
videoId: "<?=$list['url2']?>",
events: {
'onReady': onPlayerReady,
'onStateChange': onYouTubePlayerStateChange
}
});
}
var timers_w = <?=$_SESSION['view']['timer']?>,
coun = false;
function onPlayerReady(event) {
$('#blockwait').text('Запустите видео');
$('#blockwait').css({'background': 'unset', 'padding-left': 'unset'});
event.target.playVideo();
coun = true;
}
function onYouTubePlayerStateChange(a) {
if (a.data == YT.PlayerState.PLAYING) {
playing = true;
window.top.document.title = 'Просмотр видео';
interval = window.setInterval("times_go()", 1000);
} else {
$('#blocktimer').html('<h4>Запустите видео</h4>');
window.top.document.title = 'Запустите видео';
if (playing) {
window.clearInterval(interval)
}
playing = false
}
}
function times_go(){
if(coun){
var inform = info_ch;
if (inform) {
window.top.document.title = 'Просмотр видео';
$('#blockwait').hide();
$('#blocktimer').show();
timers_w--;
var text_time = timers_w;
if(text_time<10){
text_time = ""+text_time;
}
$("#blocktimer").html('Дождитесь окончания таймера: <div class="timer notranslate" id="timer">'+text_time+'</div> <span> секунд</span>');
if(timers_w==0){
window.clearInterval(interval)
window.top.document.title = 'Ожидание подтверждения';
$('#blocktimer').text('Ожидание');
coun = false;
nextstep(0, cnt);
}
} else {
$("#blocktimer").show();
$('#blockwait').hide();
$("#blocktimer").html('Ошибка! Вернитесь во вкладку');
window.top.document.title = 'Вернитесь во вкладку';
}
}
}
document.addEventListener("visibilitychange", function() {
if (document.visibilityState === 'visible') {
info_ch = true; //на странице
player.playVideo();
} else {
info_ch = false; //не на странице
player.pauseVideo();
}
});
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function changeCpt(num) {
cptcode=num;
checkClick();
}
function loadArguments() {
var xmlh=getXMLHTTP();
xmlh.onreadystatechange=function() {
if(xmlh.readyState==4 && xmlh.status==200) {
if(xmlh.responseText!='') {
$("#check").append(xmlh.responseText);
}
}
};
xmlh.open("GET", "/ajax/surfv/coin.php", true);
xmlh.setRequestHeader("Content-Type", "text/xml")
xmlh.send(null);
}
function getCaptcha() {
document.getElementById('check').style.display = 'none';
nextstep(0, cnt);
}
function checkFocus() {
setInterval(hasIsFocus, 100);
}
function timerStart() {
clearTimeout(TTimer);
TTimer=setTimeout(timerStep, 1000);
}
function checkClick() {
var xmlh=getXMLHTTP();
xmlh.onreadystatechange=function() {
if(xmlh.readyState==4 && xmlh.status==200) {
if(xmlh.responseText!='time_error' && xmlh.responseText!='create_error' && xmlh.responseText!='captcha_error') {
window.location.href = '';
}
else if(xmlh.responseText=='captcha_error') {
getCaptcha();
}
else
{
document.getElementById("check").innerHTML='Просмотр не засчитан! Повторите позже';
}
}
};
//xmlh.open("GET", "", true);
//xmlh.setRequestHeader("Content-Type", "text/xml")
//xmlh.send(null);
document.getElementById("check").innerHTML='Подождите, загрузка сайта...';
}
setTimeout(function() {
timerStart();
if (focuscheck == 1) {
checkFocus();
}
document.getElementById('blockwait').style.display = 'none';
}, 1000);
</script>
<div class="center">
<div class="table-row">
<div class="table-col col-left">
<div class="loadwait"></div>
<div id="blockverify">
<div id="blockwait">Подождите, сайт загружается...</div>
<div id="blocktimer" style="display: none;">
<form class="clockalert" name="frm" method="post" action="" onsubmit="return false;">
<input name="clock" size="3" readonly="readonly" type="text" value=""/><br />
<span></span>
</form>
</div>
</div>
</div>
<div class="table-col col-right">
<a href="<?=$list['url'];?>" class="btn btn-primary m-2" target="_blank">Перейти</a>
</div>
</div>
</div>
</div>
<div class="video">
<div id="ytPlayer">
</div>
</div>
<script src="/assets/js/surfv.frame.js"></script>
</body>
</html>
<?php
} else {
exit('Не существует или закончились просмотры');
}
?>