<?php
include('other_header.php');

$code = $_POST["code"];
$pass = $_POST["pass"];
$passmd5 = md5($_POST["pass"]);
$hash1 = $_POST["hash1"];
$hash2 = $_POST["hash2"];
$hash3 = $_POST["hash3"];
$hash4 = $_POST["hash4"];
$hash5 = $_POST["hash5"];
$hash6 = $_POST["hash6"];
$hash7 = $_POST["hash7"];
$hash8 = $_POST["hash8"];
$hash9 = $_POST["hash9"];
$recaptcharesponse = $_POST['g-recaptcha-response'];
$solvemediaresponde = $_POST["adcopy_response"];
$captchaservice = $_POST['captchaservice'];
$uip = getIP();

//CAPTCHA DETECT
if(1 == 1) {//CHECK IF CAPTCHA ENABLED
$RCactive3 = "SELECT `rcactive` FROM `Web_Settings`";
$RCactive2 = mysql_query($RCactive3) or die($RCactive3."<br/><br/>".mysql_error());
$RCactive = mysql_result($RCactive2, 0);
if ($RCactive == 1){
	//CHECK CAPTCHA SITE KEY
	$RCsite3 = "SELECT `rcsitekey` FROM `Web_Settings`";
	$RCsite2 = mysql_query($RCsite3) or die($RCsite3."<br/><br/>".mysql_error());
	$RCsite = mysql_result($RCsite2, 0);
	//CHECK CAPTCHA SECRET KEY
	$RCsecret3 = "SELECT `rcsecretkey` FROM `Web_Settings`";
	$RCsecret2 = mysql_query($RCsecret3) or die($RCsecret3."<br/><br/>".mysql_error());
	$RCsecret = mysql_result($RCsecret2, 0);
	$lang = 'en';
}

//CHECK IF CAPTCHA ENABLED
$checkcaptchastatus1 = "SELECT `smactive` FROM `Web_Settings`";
$checkcaptchastatus2 = mysql_query($checkcaptchastatus1) or die($checkcaptchastatus1."<br/><br/>".mysql_error());
$checkcaptchastatus = mysql_result($checkcaptchastatus2, 0);
if ($checkcaptchastatus == 1){
	//CHECK CAPTCHA C-KEY
	$captchac1 = "SELECT `smckey` FROM `Web_Settings`";
	$captchac2 = mysql_query($captchac1) or die($captchac1."<br/><br/>".mysql_error());
	$captchac = mysql_result($captchac2, 0);
	//CHECK CAPTCHA V-KEY
	$captchav1 = "SELECT `smvkey` FROM `Web_Settings`";
	$captchav2 = mysql_query($captchav1) or die($captchav1."<br/><br/>".mysql_error());
	$captchav = mysql_result($captchav2, 0);
	//CHECK CAPTCHA H-KEY
	$captchah1 = "SELECT `smhkey` FROM `Web_Settings`";
	$captchah2 = mysql_query($captchah1) or die($captchah1."<br/><br/>".mysql_error());
	$captchah = mysql_result($captchah2, 0);
	
}

if ($checkcaptchastatus == 1 && $RCactive == 1){
	$luck = rand(0,1);
	if ($luck == 1){
		$RCactive = 1;
		$checkcaptchastatus = 0;
	}else{
		$RCactive = 0;
		$checkcaptchastatus = 1;
	}
}
}

//LINK INFO
$queryLINK = mysql_query("SELECT * FROM Links_All WHERE code='$code'");
$arrayLINK = mysql_fetch_array($queryLINK);
$LINK_adtype = $arrayLINK['advtype'];
$LINK_username = $arrayLINK['username'];
$LINK_url = $arrayLINK['url'];
$LINK_password = $arrayLINK['password'];

// GET IPCHECK
$queryssssss = mysql_query("SELECT * FROM Web_IPcheck WHERE url='$code' AND ip='$uip'");
$numrows = mysql_num_rows($queryssssss);
if($numrows == 0) {
	$hash1F = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 45);
	$hash2F = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 45);
	$hash3F = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 45);
	$hash4F = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 45);
	$hash5F = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 45);
	$hash6F = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 45);
	$hash7F = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 45);
	$hash8F = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 45);
	$hash9F = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 45);
	$checkforads = mysql_query("SELECT * FROM Ads_All WHERE adtype='$LINK_adtype' AND countries='$country_name' AND credits > '0' AND active = '1' AND approved = '1' ORDER BY RAND()");
	$numcrows = mysql_num_rows($checkforads); 
	if($numcrows != 0) {
		$fetchurl = mysql_fetch_array($checkforads);
		$genadid = $fetchurl['id'];
	}else {
		$checkforads = mysql_query("SELECT * FROM Ads_All WHERE adtype='$LINK_adtype' AND countries='ALL' AND credits > '0' AND active = '1' AND approved = '1' ORDER BY RAND()");
		$numcrows = mysql_num_rows($checkforads); 
		if($numcrows != 0) {
			$fetchurl = mysql_fetch_array($checkforads);
			$genadid = $fetchurl['id'];
			$shownoad4u = 'false';
		}else {
			$genadid = "noadforyou";
			if($numcrowsaaa987 == 0) {
				$shownoad4u = 'true';
			}
		}
	}
	$sqledit = mysql_query("INSERT INTO Web_IPcheck VALUES('','$code','$uip','$hash1F','$hash2F','$hash3F','$hash4F','$hash5F','$hash6F','$hash7F','$hash8F','$hash9F','$genadid','0')");
}
$mysqlfetcharraytogether = mysql_fetch_array($queryssssss);
if($mysqlfetcharraytogether['adid'] == 'noadforyou') {
	$checkforads = mysql_query("SELECT * FROM Ads_All WHERE adtype='$LINK_adtype' AND countries='$country_name' AND credits > '0' AND active = '1' AND approved = '1' ORDER BY RAND()");
	$numcrows = mysql_num_rows($checkforads); 
	if($numcrows != 0) {
		$fetchurl = mysql_fetch_array($checkforads);
		$genadid = $fetchurl['id'];
		$shownoad4u = 'false';
	}else {
		$checkforads = mysql_query("SELECT * FROM Ads_All WHERE adtype='$LINK_adtype' AND countries='ALL' AND credits > '0' AND active = '1' AND approved = '1' ORDER BY RAND()");
		$numcrows = mysql_num_rows($checkforads); 
		if($numcrows != 0) {
			$fetchurl = mysql_fetch_array($checkforads);
			$genadid = $fetchurl['id'];
		}else {
			$genadid = "noadforyou";
			if($numcrowsaaa987 == 0) {
				$shownoad4u = 'true';
			}
		}
	}
	$changetoplay = mysql_query("UPDATE Web_IPcheck SET adid='$genadid' WHERE url='$code' AND ip='$uip'");
}

$query2 = mysql_query("SELECT * FROM Web_IPcheck WHERE url='$code' AND ip='$uip'");
$numcrowsaaa987 = mysql_num_rows($query2); 
if($numcrowsaaa987 == 0) {
	$checkforads = mysql_query("SELECT * FROM Ads_All WHERE adtype='$LINK_adtype' AND countries='$country_name' AND credits > '0' AND active = '1' AND approved = '1' ORDER BY RAND()");
	$numcrows = mysql_num_rows($checkforads); 
	if($numcrows != 0) {
		$fetchurl = mysql_fetch_array($checkforads);
		$genadid = $fetchurl['id'];
		$shownoad4u = 'false';
	}else {
		$checkforads = mysql_query("SELECT * FROM Ads_All WHERE adtype='$LINK_adtype' AND countries='ALL' AND credits > '0' AND active = '1' AND approved = '1' ORDER BY RAND()");
		$numcrows = mysql_num_rows($checkforads); 
		if($numcrows != 0) {
			$fetchurl = mysql_fetch_array($checkforads);
			$genadid = $fetchurl['id'];
		}else {
			$genadid = "noadforyou";
			if($numcrowsaaa987 == 0) {
				$shownoad4u = 'true';
			}
		}
	}
	$changetoplay = mysql_query("UPDATE Web_IPcheck SET adid='$genadid' WHERE url='$code' AND ip='$uip'");
	$query2 = mysql_query("SELECT * FROM Web_IPcheck WHERE url='$code' AND ip='$uip'");
}else {
	$shownoad4u = 'false';
}
$qqf = mysql_fetch_array($query2);
$D_code = $qqf['url'];
$D_ip = $qqf['ip'];
$D_hash1 = $qqf['hash1'];
$D_hash2 = $qqf['hash2'];
$D_hash3 = $qqf['hash3'];
$D_hash4 = $qqf['hash4'];
$D_hash5 = $qqf['hash5'];
$D_hash6 = $qqf['hash6'];
$D_hash7 = $qqf['hash7'];
$D_hash8 = $qqf['hash8'];
$D_hash9 = $qqf['hash9'];
$D_adid = $qqf['adid'];
$D_uses = $qqf['uses'];
$numcrowsaaa989 = mysql_num_rows($query2); 
if($numcrowsaaa989 == 0) {
	$shownoad4u = 'true';
}else {
	$shownoad4u = 'false';
}

$queryADS = mysql_query("SELECT * FROM Ads_All WHERE id='$D_adid'");
$arrayADS = mysql_fetch_array($queryADS);
$numcrowsaaa123 = mysql_num_rows($queryADS);
if($numcrowsaaa123 == 0) {
	$shownoad4u = 'true';
}else {
	$shownoad4u = 'false';
} 
$AD_adtype = $arrayADS['adtype'];
$AD_generalurl = $arrayADS['url'];
$AD_mediaurl = $arrayADS['imageurl'];
$AD_owner = $arrayADS['owner'];
$AD_countries = $arrayADS['countries'];

$getvalues = mysql_query("SELECT * FROM Web_Countries WHERE country='$AD_countries'");
$fgvalues = mysql_fetch_array($getvalues);
	if($AD_adtype == 'interstitial') {
		$countryone_ppv = $fgvalues['ppv'];
		$countryone_cpv = $fgvalues['ppvadv'];
	}
	if($AD_adtype == 'video') {
		$countryone_ppv = $fgvalues['ppvvideo'];
		$countryone_cpv = $fgvalues['cpvvideo'];
	}
	if($AD_adtype == 'banner') {
		$countryone_ppv = $fgvalues['ppvb'];
		$countryone_cpv = $fgvalues['ppvbadv'];
	}

?>
	<nav id="top_navbar" class="navbar navbar-inverse navbar-fixed-top" role="navigation" style="margin: 0px; width: 100%;"><!-- WHITE navbar-superhero -->
    <div class="container">
      <!-- Brand and toggle get grouped for better mobile display -->
      <div class="navbar-header navbar-right">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#main-nav">
          <span class="sr-only">Toggle navigation</span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
      </div>
      <?php
			if($LINK_adtype == 'video' && isset($_POST['STEP3'])) {
				?>
				<button onclick="javascript:manualfunc();" id="PlayPauseButton" style="position: fixed; width: 10%; max-width: 10%; padding: 10px; top: 0px; left: 45%;" class="btn btn-success"><i class="fa fa-play"></i></button>
				<div id="areav5">
					<button onclick="javascript:manualfunc();" id="buttonv" style="position: fixed; width: 30%; max-width: 30%; padding: 10px; bottom: 0px; left: 35%;" class="btn btn-success"><i class="fa fa-circle-o-notch fa-spin"></i> Ready</button>
				</div>
				<?php
			}
		?>
		<?php
			if($LINK_adtype == 'interstitial' && isset($_POST['STEP3'])) {
				?>
				<div id="areav5">
					<button onclick="javascript:manualfunc();" id="buttonint" style="position: fixed; width: 30%; max-width: 30%; padding: 10px; top: 0px; left: 35%;" class="btn btn-success"><i class="fa fa-circle-o-notch fa-spin"></i> Loading please wait...</button>
				</div>
				<?php
			}
		?>
		<?php
			if($LINK_adtype == 'banner' && isset($_POST['STEP3'])) {
				?>
				<div id="areav5">
					<button onclick="javascript:manualfunc();" id="buttonbanner" style="position: fixed; width: 30%; max-width: 30%; padding: 10px; top: 0px; left: 35%;" class="btn btn-success"><i class="fa fa-circle-o-notch fa-spin"></i> Loading please wait...</button>
				</div>
				<a target="_blank" href="<?php echo $AD_generalurl; ?>"><img id="bannerimageid" style="" src="<?php echo $AD_mediaurl; ?>"></a>
				<?php
			}
		?>
      <!-- Collect the nav links, forms, and other content for toggling -->
      <div class="collapse navbar-collapse" id="main-nav">
			<?php
			if($LINK_adtype == 'video' && isset($_POST['STEP3'])) {
				?>
			<ul class="nav navbar-nav">
			<li>
				<?php 
  		if($showicon == '1') { 
  		?>
			<a class="navbar-brand" target="_blank" href="f.home"><img style="margin-top: -6px; height: 35px;" src="<?php echo $iconurl; ?>"></a>
		<?php
		}
  		if($showtitle == '1') { 
  		?>
			<a class="navbar-brand" href="f.home"><?php echo"$title"?></a>
		<?php
		}
		?>
			</li>
			</ul>
			<ul class="nav navbar-nav navbar-right">
			<li id="areav2">
				<a href="javascript:setmute();" id="muteButton"> <i class="fa fa-volume-up"></i> / <i class="fa fa-volume-off"></i></a>
			</li>
			<li id="areav4">
				<a href="javascript:window.open('<?php echo $AD_generalurl; ?>');" id="muteButton"> <?php echo $a015;?></a>
			</li>
			</ul>
			<?php
			}elseif($LINK_adtype == 'interstitial' && isset($_POST['STEP3'])) {
				?>
			<ul class="nav navbar-nav">
			<li>
				<?php 
  		if($showicon == '1') { 
  		?>
			<a class="navbar-brand" target="_blank" href="f.home"><img style="margin-top: -6px; height: 35px;" src="<?php echo $iconurl; ?>"></a>
		<?php
		}
  		if($showtitle == '1') { 
  		?>
			<a class="navbar-brand" href="f.home"><?php echo"$title"?></a>
		<?php
		}
		?>
			</li>
			</ul>
			<?php
			}elseif($LINK_adtype == 'banner' && isset($_POST['STEP3'])) {
				?>
			<ul class="nav navbar-nav">
			<li>
				<?php 
  		if($showicon == '1') { 
  		?>
			<a class="navbar-brand" target="_blank" href="f.home"><img style="margin-top: -6px; height: 35px;" src="<?php echo $iconurl; ?>"></a>
		<?php
		}
  		if($showtitle == '1') { 
  		?>
			<a class="navbar-brand" href="f.home"><?php echo"$title"?></a>
		<?php
		}
		?>
			</li>
			</ul>
			</ul>
			<?php
			}else {
			?>
			<ul class="nav navbar-nav">
			<li>
				<?php 
  		if($showicon == '1') { 
  		?>
			<a class="navbar-brand" target="_blank" href="f.home"><img style="margin-top: -6px; height: 35px;" src="<?php echo $iconurl; ?>"></a>
		<?php
		}
  		if($showtitle == '1') { 
  		?>
			<a class="navbar-brand" href="f.home"><?php echo"$title"?></a>
		<?php
		}
		?>
			</li>
			</ul>
			<ul class="nav navbar-nav navbar-right">
			<li>
				<a href="#"> <i class="fa fa-plus"></i> Showing <?php echo $AD_adtype;?> AD</a>
			</li>
			</ul>
			<?php
			}
			?>
      </div><!-- /.Ad could not be loaded. Ad contains scripts which is not allowed here (too much redirections), or was blocked by malware controller. -->
    </div>
  </nav>
<div id="fullweb" style="padding: 0px;height: 100%;background: none repeat scroll 0% 0% rgb(255, 255, 255);">
<?php
if($LINK_adtype != 'video' && isset($_POST['STEP3'])) {
?>
<div id="notloaded" style="background: none repeat scroll 0% 0% rgb(255, 255, 255); color: rgb(0, 0, 0); padding: 0px; padding-top: 40px; height: 100%; width: 100%;">
	<p id="loadtext" style="margin-top: 100px;">
		<center>
			<h1 id="h1loadtext"><i class="fa fa-circle-o-notch fa-spin"></i> Loading ...</h1>
		</center>
	</p>
</div>
<?php
}

if(isset($_POST['STEP1'])) {
	echo "<!-- /.STEP1 -->";
}
if(isset($_POST['STEP2'])) {
	echo "<!-- /.STEP2 -->";
}
if(isset($_POST['STEP3'])) {
	echo "<!-- /.STEP3 -->";
}
if(isset($_POST['STEP4'])) {
	echo "<!-- /.STEP4 -->";
}

if(isset($_POST['STEP4'])) {
	//HASH2 == HASH1
	//HASH2 == HASH2
	//HASH3 == HASH3			REDIRECT
	if(!empty($LINK_password)) {
		if($passmd5 == $LINK_password) {
			if($D_hash1 == $hash1) {
				if($D_hash2 == $hash2) {
					if($D_hash3 == $hash3) {
						if($AD_adtype != 'banner') {
							if($D_uses == '0') {
							// REVENUE CALCULATION
							$revenue = $countryone_cpv - $countryone_ppv;
							$ref = $revenue * $sa['ppvr'];
							// ADVERTISER
							$changetoplay = mysql_query("UPDATE Ads_All SET credits=credits - '1' WHERE id='$D_adid'");
							$queryaaa = mysql_query("SELECT * FROM Accounts_Classic_Advertisers WHERE username='$AD_owner'");
							$numrowsaaa = mysql_num_rows($queryaaa);
							if($numrowsaaa != 0) {
								$arrayuser = mysql_fetch_array($queryaaa);
								$refida = $arrayuser['refid'];
								$updateads = mysql_query("UPDATE Accounts_Classic_Advertisers SET date7=date7 + '1' WHERE username='$AD_owner'");
							}
							// PUBLISHER
							$queryaaa = mysql_query("SELECT * FROM Accounts_Classic_Publishers WHERE username='$LINK_username'");
							$numrowsaaa = mysql_num_rows($queryaaa);
							if($numrowsaaa != 0) {
								$arrayuser = mysql_fetch_array($queryaaa);
								$refid = $arrayuser['refid'];
								$viewsupdatee = mysql_query("UPDATE Links_All SET views=views + '1' WHERE code='$code'");
								$earningsupdatee = mysql_query("UPDATE Links_All SET mearned=mearned + '$countryone_ppv' WHERE code='$code'");
								$updateads = mysql_query("UPDATE Accounts_Classic_Publishers SET date7=date7 + '1' WHERE username='$LINK_username'");
								$changetoplay = mysql_query("UPDATE Accounts_Classic_Publishers SET balance=balance + '$countryone_ppv',uplineearnings='$ref' WHERE username='$LINK_username'");
							}
							// REF OF ADVERTISER
							$queryaaa = mysql_query("SELECT * FROM Accounts_Classic_Publishers WHERE username='$refida'");
							$numrowsaaa = mysql_num_rows($queryaaa);
							if($numrowsaaa != 0) {
								$revenue = $revenue - $ref;
								$changetoplay = mysql_query("UPDATE Accounts_Classic_Publishers SET balance=balance + '$ref',refearnings='$ref' WHERE username='$refida'");
								$graphupp = mysql_query("UPDATE Accounts_Classic_Publishers SET rdate7=rdate7+1 WHERE username='$refida'");
							}
							// REF OF PUBLISHER
							$queryaaa = mysql_query("SELECT * FROM Accounts_Classic_Publishers WHERE username='$refid'");
							$numrowsaaa = mysql_num_rows($queryaaa);
							if($numrowsaaa != 0) {
								$revenue = $revenue - $ref;
								$changetoplay = mysql_query("UPDATE Accounts_Classic_Publishers SET balance=balance + '$ref',refearnings='$ref' WHERE username='$refid'");
								$graphupp = mysql_query("UPDATE Accounts_Classic_Publishers SET rdate7=rdate7+1 WHERE username='$refid'");
							}
							// REVENUE
							$changetoplaya = mysql_query("UPDATE Web_Revenue SET revenue=revenue + '$revenue'");
							$changetoplaya = mysql_query("UPDATE Web_IPcheck SET uses='1' WHERE url='$code' AND ip='$uip'");
							}
						}
						echo"<script type='text/javascript'>window.location.replace('$LINK_url'); </script>";
					}
				}
			}
		}
	}else	if($D_hash1 == $hash1) {
		if($D_hash2 == $hash2) {
			if($D_hash3 == $hash3) {
				if($AD_adtype != 'banner') {
							if($D_uses == '0') {
							// REVENUE CALCULATION
							$revenue = $countryone_cpv - $countryone_ppv;
							$ref = $revenue * $sa['ppvr'];
							// ADVERTISER
							$changetoplay = mysql_query("UPDATE Ads_All SET credits=credits - '1' WHERE id='$D_adid'");
							$queryaaa = mysql_query("SELECT * FROM Accounts_Classic_Advertisers WHERE username='$AD_owner'");
							$numrowsaaa = mysql_num_rows($queryaaa);
							if($numrowsaaa != 0) {
								$arrayuser = mysql_fetch_array($queryaaa);
								$refida = $arrayuser['refid'];
								$updateads = mysql_query("UPDATE Accounts_Classic_Advertisers SET date7=date7 + '1' WHERE username='$AD_owner'");
							}
							// PUBLISHER
							$queryaaa = mysql_query("SELECT * FROM Accounts_Classic_Publishers WHERE username='$LINK_username'");
							$numrowsaaa = mysql_num_rows($queryaaa);
							if($numrowsaaa != 0) {
								$arrayuser = mysql_fetch_array($queryaaa);
								$refid = $arrayuser['refid'];
								$viewsupdatee = mysql_query("UPDATE Links_All SET views=views + '1' WHERE code='$code'");
								$earningsupdatee = mysql_query("UPDATE Links_All SET mearned=mearned + '$countryone_ppv' WHERE code='$code'");
								$updateads = mysql_query("UPDATE Accounts_Classic_Publishers SET date7=date7 + '1' WHERE username='$LINK_username'");
								$changetoplay = mysql_query("UPDATE Accounts_Classic_Publishers SET balance=balance + '$countryone_ppv',uplineearnings='$ref' WHERE username='$LINK_username'");
							}
							// REF OF ADVERTISER
							$queryaaa = mysql_query("SELECT * FROM Accounts_Classic_Publishers WHERE username='$refida'");
							$numrowsaaa = mysql_num_rows($queryaaa);
							if($numrowsaaa != 0) {
								$revenue = $revenue - $ref;
								$changetoplay = mysql_query("UPDATE Accounts_Classic_Publishers SET balance=balance + '$ref',refearnings='$ref' WHERE username='$refida'");
								$graphupp = mysql_query("UPDATE Accounts_Classic_Publishers SET rdate7=rdate7+1 WHERE username='$refida'");
							}
							// REF OF PUBLISHER
							$queryaaa = mysql_query("SELECT * FROM Accounts_Classic_Publishers WHERE username='$refid'");
							$numrowsaaa = mysql_num_rows($queryaaa);
							if($numrowsaaa != 0) {
								$revenue = $revenue - $ref;
								$changetoplay = mysql_query("UPDATE Accounts_Classic_Publishers SET balance=balance + '$ref',refearnings='$ref' WHERE username='$refid'");
								$graphupp = mysql_query("UPDATE Accounts_Classic_Publishers SET rdate7=rdate7+1 WHERE username='$refid'");
							}
							// REVENUE
							$changetoplaya = mysql_query("UPDATE Web_Revenue SET revenue=revenue + '$revenue'");
							$changetoplaya = mysql_query("UPDATE Web_IPcheck SET uses='1' WHERE url='$code' AND ip='$uip'");
						}
						}
						echo"<script type='text/javascript'>window.location.replace('$LINK_url'); </script>";
			}
		}
	}
}elseif(isset($_POST['STEP3'])) {
	if ($checkcaptchastatus == 1 || $RCactive == 1){
			$recaptcha=$_POST['g-recaptcha-response'];
			$solvemediaresponde = $_POST["adcopy_response"];
			if (isset($_POST["captchaservice"])) {
				$captchaservice = $_POST["captchaservice"];
				if ($captchaservice == 'solvemedia'){
					if (empty($solvemediaresponde)){
						?>
						<form method='post' name='frm'>
							<input type="hidden" name="error" value="invalid captcha">
						</form>
						<script language="JavaScript">
							document.frm.submit();
						</script>
					<?php	
					}
				}else if ($captchaservice == 'recaptcha'){
					if (empty($recaptcha)){
						?>
						<form method='post' name='frm'>
							<input type="hidden" name="error" value="invalid captcha">
						</form>
						<script language="JavaScript">
							document.frm.submit();
						</script>
					<?php	
					}
				}
			}
			if(!empty($recaptcha))
			{
				$google_url = "https://www.google.com/recaptcha/api/siteverify";
				$secret = $RCsecret;
				$ip = $_SERVER['REMOTE_ADDR'];
				$url = $google_url."?secret=".$secret."&response=".$recaptcha."&remoteip=".$ip;
				$res = getCurlData($url);
				$res = json_decode($res, true);
				if($res['success'])
				{}else{
					?>
						<form method='post' name='frm'>
							<input type="hidden" name="error" value="invalid captcha">
						</form>
						<script language="JavaScript">
							document.frm.submit();
						</script>
					<?php	
				}
			}else{
				require_once("solvemedialib.php");
				$privkey = $captchav;
				$hashkey = $captchah;
				$solvemedia_response = solvemedia_check_answer($privkey,
						$_SERVER["REMOTE_ADDR"],
						$_POST["adcopy_challenge"],
						$_POST["adcopy_response"],
						$hashkey);
				if (!$solvemedia_response->is_valid) {
					?>
						<form method='post' name='frm'>
							<input type="hidden" name="error" value="invalid captcha">
						</form>
						<script language="JavaScript">
							document.frm.submit();
						</script>
					<?php	
					die('invalid captcha');
				}
			}
		}
	//HASH2 == HASH1
	//HASH2 == HASH2			SHOW AD >> WITH HASH3 PASS //CAPTCHA VALIDATION
	if(!empty($LINK_password)) {
		if($passmd5 == $LINK_password) {
			if($D_hash1 == $hash1) {
				if($D_hash2 == $hash2) {
			if($LINK_adtype == 'video') {
						if($shownoad4u == 'true') {
						?>
							<!-- /.NO AD 4 U -->
							<p style="margin-top: 100px;"><h1>There isn't available ad for you right now. Please visit us later.</h1></p>
						<?php
						}else {
						?>
							<!-- /.VIDEO -->
							<div style="max-height: 100%" class="cont" id="container1">&nbsp; LOADING...</div>
						<?php
						}
			}
			if($LINK_adtype == 'interstitial') {
						if($shownoad4u == 'true') {
						?>
							<!-- /.NO AD 4 U -->
							<p style="margin-top: 100px;"><h1>There isn't available ad for you right now. Please visit us later.</h1></p>
						<?php
						}else {
						$AD_generalurl = str_replace('&','ANDTHISISJUSTJOKESOCOMEON',$AD_generalurl);
						$AD_generalurl = str_replace('?','QUESTIONSYMBOLRIGHTHERE',$AD_generalurl);
						?>
							<!-- /.INT -->
							<iframe id="i_frame" style="padding-top: 40px;" src="<?php echo $mainurl;?>system/general/components/popblocker/framefilter.php?furl=<?php echo $AD_generalurl; ?>" scrolling="yes" frameBorder="0" width="100%" height="100%">Browser not supported</iframe>
						<?php
						}
			}
			if($LINK_adtype == 'banner') {
						if($shownoad4u == 'true') {
						?>
							<!-- /.NO AD 4 U -->
							<p style="margin-top: 100px;"><h1>There isn't available ad for you right now. Please visit us later.</h1></p>
						<?php
						}else {
						$LINK_url = str_replace('&','ANDTHISISJUSTJOKESOCOMEON',$LINK_url);
						$LINK_url = str_replace('?','QUESTIONSYMBOLRIGHTHERE',$LINK_url);
						?>
							<!-- /.BANNER -->
							<iframe id="i_frame" style="padding-top: 40px;" src="<?php echo $mainurl;?>system/general/components/popblocker/framefilter.php?furl=<?php echo $LINK_url; ?>" scrolling="yes" frameBorder="0" width="100%" height="100%">Browser not supported</iframe>
						<?php
						}
			}
						?>
					<form style='hidden' method='post' id="frmvideo" name='frmvideo'>
						<input type="hidden" name="STEP1" value="yes">
						<input type="hidden" name="STEP2" value="yes">
						<input type="hidden" name="STEP3" value="yes">
						<input type="hidden" name="STEP4" value="yes">
						<input type="hidden" name="hash1" value="<?php echo $D_hash1;?>">
						<input type="hidden" name="hash2" value="<?php echo $D_hash2;?>">
						<input type="hidden" name="hash3" value="<?php echo $D_hash3;?>">
						<?php if(isset($_POST['pass'])) {?><input type="hidden" name="pass" value="<?php echo $pass;?>"><?php } ?>
					</form>
					<?php
					if($AD_adtype == 'banner') {
						if($D_uses == '0') {
							// REVENUE CALCULATION
							$revenue = $countryone_cpv - $countryone_ppv;
							$ref = $revenue * $sa['ppvr'];
							// ADVERTISER
							$changetoplay = mysql_query("UPDATE Ads_All SET credits=credits - '1' WHERE id='$D_adid'");
							$queryaaa = mysql_query("SELECT * FROM Accounts_Classic_Advertisers WHERE username='$AD_owner'");
							$numrowsaaa = mysql_num_rows($queryaaa);
							if($numrowsaaa != 0) {
								$arrayuser = mysql_fetch_array($queryaaa);
								$refida = $arrayuser['refid'];
								$updateads = mysql_query("UPDATE Accounts_Classic_Advertisers SET date7=date7 + '1' WHERE username='$AD_owner'");
							}
							// PUBLISHER
							$queryaaa = mysql_query("SELECT * FROM Accounts_Classic_Publishers WHERE username='$LINK_username'");
							$numrowsaaa = mysql_num_rows($queryaaa);
							if($numrowsaaa != 0) {
								$arrayuser = mysql_fetch_array($queryaaa);
								$refid = $arrayuser['refid'];
								$viewsupdatee = mysql_query("UPDATE Links_All SET views=views + '1' WHERE code='$code'");
								$earningsupdatee = mysql_query("UPDATE Links_All SET mearned=mearned + '$countryone_ppv' WHERE code='$code'");
								$updateads = mysql_query("UPDATE Accounts_Classic_Publishers SET date7=date7 + '1' WHERE username='$LINK_username'");
								$changetoplay = mysql_query("UPDATE Accounts_Classic_Publishers SET balance=balance + '$countryone_ppv',uplineearnings='$ref' WHERE username='$LINK_username'");
							}
							// REF OF ADVERTISER
							$queryaaa = mysql_query("SELECT * FROM Accounts_Classic_Publishers WHERE username='$refida'");
							$numrowsaaa = mysql_num_rows($queryaaa);
							if($numrowsaaa != 0) {
								$revenue = $revenue - $ref;
								$changetoplay = mysql_query("UPDATE Accounts_Classic_Publishers SET balance=balance + '$ref',refearnings='$ref' WHERE username='$refida'");
								$graphupp = mysql_query("UPDATE Accounts_Classic_Publishers SET rdate7=rdate7+1 WHERE username='$refida'");
							}
							// REF OF PUBLISHER
							$queryaaa = mysql_query("SELECT * FROM Accounts_Classic_Publishers WHERE username='$refid'");
							$numrowsaaa = mysql_num_rows($queryaaa);
							if($numrowsaaa != 0) {
								$revenue = $revenue - $ref;
								$changetoplay = mysql_query("UPDATE Accounts_Classic_Publishers SET balance=balance + '$ref',refearnings='$ref' WHERE username='$refid'");
								$graphupp = mysql_query("UPDATE Accounts_Classic_Publishers SET rdate7=rdate7+1 WHERE username='$refid'");
							}
							// REVENUE
							$changetoplaya = mysql_query("UPDATE Web_Revenue SET revenue=revenue + '$revenue'");
							$changetoplaya = mysql_query("UPDATE Web_IPcheck SET uses='1' WHERE url='$code' AND ip='$uip'");
						}
						}
				}
			}
		}else {
		?>
		<form method='post' name='frmagain'>
			<input type="hidden" name="again" value="yes">
		</form>
		<script language="JavaScript">
			document.frmagain.submit();
		</script>
		<?php
		}
	}else	if($D_hash1 == $hash1) {
		if($D_hash2 == $hash2) {
			if($LINK_adtype == 'video') {
						if($shownoad4u == 'true') {
						?>
							<!-- /.NO AD 4 U -->
							<p style="margin-top: 100px;"><h1>There isn't available ad for you right now. Please visit us later.</h1></p>
						<?php
						}else {
						?>
							<!-- /.VIDEO -->
							<div style="max-height: 100%" class="cont" id="container1">&nbsp; LOADING...</div>
						<?php
						}
			}
			if($LINK_adtype == 'interstitial') {
						if($shownoad4u == 'true') {
						?>
							<!-- /.NO AD 4 U -->
							<p style="margin-top: 100px;"><h1>There isn't available ad for you right now. Please visit us later.</h1></p>
						<?php
						}else {
						$AD_generalurl = str_replace('&','ANDTHISISJUSTJOKESOCOMEON',$AD_generalurl);
						$AD_generalurl = str_replace('?','QUESTIONSYMBOLRIGHTHERE',$AD_generalurl);
						?>
							<!-- /.INT -->
							<iframe id="i_frame" style="padding-top: 40px;" src="<?php echo $mainurl;?>system/general/components/popblocker/framefilter.php?furl=<?php echo $AD_generalurl; ?>" scrolling="yes" frameBorder="0" width="100%" height="100%">Browser not supported</iframe>
						<?php
						}
			}
			if($LINK_adtype == 'banner') {
						if($shownoad4u == 'true') {
						?>
							<!-- /.NO AD 4 U -->
							<p style="margin-top: 100px;"><h1>There isn't available ad for you right now. Please visit us later.</h1></p>
						<?php
						}else {
						$LINK_url = str_replace('?','QUESTIONSYMBOLRIGHTHERE',$LINK_url);
						$LINK_url = str_replace('&','ANDTHISISJUSTJOKESOCOMEON',$LINK_url);
						?>
							<!-- /.BANNER -->
							<iframe id="i_frame"  style="padding-top: 40px;" src="<?php echo $mainurl;?>system/general/components/popblocker/framefilter.php?furl=<?php echo $LINK_url; ?>" scrolling="yes" frameBorder="0" width="100%" height="100%">Browser not supported</iframe>
						<?php
						}
			}
			if($AD_adtype == 'banner') {
						if($D_uses == '0') {
							// REVENUE CALCULATION
							$revenue = $countryone_cpv - $countryone_ppv;
							$ref = $revenue * $sa['ppvr'];
							// ADVERTISER
							$changetoplay = mysql_query("UPDATE Ads_All SET credits=credits - '1' WHERE id='$D_adid'");
							$queryaaa = mysql_query("SELECT * FROM Accounts_Classic_Advertisers WHERE username='$AD_owner'");
							$numrowsaaa = mysql_num_rows($queryaaa);
							if($numrowsaaa != 0) {
								$arrayuser = mysql_fetch_array($queryaaa);
								$refida = $arrayuser['refid'];
								$updateads = mysql_query("UPDATE Accounts_Classic_Advertisers SET date7=date7 + '1' WHERE username='$AD_owner'");
							}
							// PUBLISHER
							$queryaaa = mysql_query("SELECT * FROM Accounts_Classic_Publishers WHERE username='$LINK_username'");
							$numrowsaaa = mysql_num_rows($queryaaa);
							if($numrowsaaa != 0) {
								$arrayuser = mysql_fetch_array($queryaaa);
								$refid = $arrayuser['refid'];
								$viewsupdatee = mysql_query("UPDATE Links_All SET views=views + '1' WHERE code='$code'");
								$earningsupdatee = mysql_query("UPDATE Links_All SET mearned=mearned + '$countryone_ppv' WHERE code='$code'");
								$updateads = mysql_query("UPDATE Accounts_Classic_Publishers SET date7=date7 + '1' WHERE username='$LINK_username'");
								$changetoplay = mysql_query("UPDATE Accounts_Classic_Publishers SET balance=balance + '$countryone_ppv',uplineearnings='$ref' WHERE username='$LINK_username'");
							}
							// REF OF ADVERTISER
							$queryaaa = mysql_query("SELECT * FROM Accounts_Classic_Publishers WHERE username='$refida'");
							$numrowsaaa = mysql_num_rows($queryaaa);
							if($numrowsaaa != 0) {
								$revenue = $revenue - $ref;
								$changetoplay = mysql_query("UPDATE Accounts_Classic_Publishers SET balance=balance + '$ref',refearnings='$ref' WHERE username='$refida'");
								$graphupp = mysql_query("UPDATE Accounts_Classic_Publishers SET rdate7=rdate7+1 WHERE username='$refida'");
							}
							// REF OF PUBLISHER
							$queryaaa = mysql_query("SELECT * FROM Accounts_Classic_Publishers WHERE username='$refid'");
							$numrowsaaa = mysql_num_rows($queryaaa);
							if($numrowsaaa != 0) {
								$revenue = $revenue - $ref;
								$changetoplay = mysql_query("UPDATE Accounts_Classic_Publishers SET balance=balance + '$ref',refearnings='$ref' WHERE username='$refid'");
								$graphupp = mysql_query("UPDATE Accounts_Classic_Publishers SET rdate7=rdate7+1 WHERE username='$refid'");
							}
							// REVENUE
							$changetoplaya = mysql_query("UPDATE Web_Revenue SET revenue=revenue + '$revenue'");
							$changetoplaya = mysql_query("UPDATE Web_IPcheck SET uses='1' WHERE url='$code' AND ip='$uip'");
						}
			}
			?>
			<form style='hidden' method='post' id="frmvideo" name='frmvideo'>
				<input type="hidden" name="STEP1" value="yes">
				<input type="hidden" name="STEP2" value="yes">
				<input type="hidden" name="STEP3" value="yes">
				<input type="hidden" name="STEP4" value="yes">
				<input type="hidden" name="hash1" value="<?php echo $D_hash1;?>">
				<input type="hidden" name="hash2" value="<?php echo $D_hash2;?>">
				<input type="hidden" name="hash3" value="<?php echo $D_hash3;?>">
				<?php if(isset($_POST['pass'])) {?><input type="hidden" name="pass" value="<?php echo $pass;?>"><?php } ?>
			</form>
			<?php
		}
	}
}else if(isset($_POST['STEP2'])) {
	//IF PASSMD5 == LINK_password
	//HASH1 == HASH1			IF CAPTCHA >> WITH HASH2 PASS
	if($checkcaptchastatus == 0 && $RCactive == 0) {
		?>
		<form method='post' name='frm'>
			<input type="hidden" name="STEP1" value="yes">
			<input type="hidden" name="STEP2" value="yes">
			<input type="hidden" name="STEP3" value="yes">
			<input type="hidden" name="hash1" value="<?php echo $D_hash1;?>">
			<input type="hidden" name="hash2" value="<?php echo $D_hash2;?>">
			<?php if(isset($_POST['pass'])) {?><input type="hidden" name="pass" value="<?php echo $pass;?>"><?php } ?>
		</form>
		<script language="JavaScript">
			document.frm.submit();
		</script>
		<?php
	}else {
	if(!empty($LINK_password)) {
		if($passmd5 == $LINK_password) {
			$passwordstatus = 1;
			if($D_hash1 == $hash1) {
				$hashstatus = 1;
				?>
					<div style="padding: 90px 40px 0px" class="row">
      <div class="col-md-8 col-md-offset-2">
		<div class="row">
			<div class="col-md-8 col-md-offset-2">
				<form name="frm" id="password" action="" method="POST">
						<center>
						<form id="formsubmitcaptcha" style='max-height:0px' method='POST'>
					<?php 
						if ($checkcaptchastatus == 1){
					?>
							<input type="hidden" name="captchaservice" value="solvemedia">
					<?php
							require_once("solvemedialib.php");			//include the Solve Media library 
							echo solvemedia_get_html("$captchac");	//outputs the widget
						}else if ($RCactive == 1){
					?>
							<input type="hidden" name="captchaservice" value="recaptcha">
							<div class="g-recaptcha" data-sitekey="<?php echo $RCsite; ?>"></div>
							<script type="text/javascript"
								src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&hl=<?php echo $lang; ?>">
							</script>
					<?php
						}
					?>
					<input class='btn btn-info' value='<?php echo $a094;?>' name='captchanext' type='submit'>
					<input type="hidden" name="hash1" value="<?php echo $D_hash1;?>">
					<input type="hidden" name="hash2" value="<?php echo $D_hash2;?>">
					<?php if(isset($_POST['pass'])) {?><input type="hidden" name="pass" value="<?php echo $pass;?>"><?php } ?>
					<input type="hidden" name="STEP1" value="yes">
					<input type="hidden" name="STEP2" value="yes">
					<input type="hidden" name="STEP3" value="yes">
				</form>
						</center>
				</form>
			</div>
        </div>
      </div>
    </div>
				<?php
			}else {
			?>
			<form method='post' name='frm'>
				<input type="hidden" name="error" value="bad hash">
			</form>
			<script language="JavaScript">
				document.frm.submit();
			</script>
			<?php	
			}
		}else {
		?>
		<form method='post' name='frmagain'>
			<input type="hidden" name="again" value="yes">
		</form>
		<script language="JavaScript">
			document.frmagain.submit();
		</script>
		<?php
		}
	}else {
		if($D_hash1 == $hash1) {
			$hashstatus = 1;
			?>
				<div style="padding: 90px 40px 0px" class="row">
      <div class="col-md-8 col-md-offset-2">
		<div class="row">
			<div class="col-md-8 col-md-offset-2">
				<form name="frm" id="password" action="" method="POST">
						<center>
						<form id="formsubmitcaptcha" style='max-height:0px' method='POST'>
					<?php 
						if ($checkcaptchastatus == 1){
					?>
							<input type="hidden" name="captchaservice" value="solvemedia">
					<?php
							require_once("solvemedialib.php");			//include the Solve Media library 
							echo solvemedia_get_html("$captchac");	//outputs the widget
						}else if ($RCactive == 1){
					?>
							<input type="hidden" name="captchaservice" value="recaptcha">
							<div class="g-recaptcha" data-sitekey="<?php echo $RCsite; ?>"></div>
							<script type="text/javascript"
								src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&hl=<?php echo $lang; ?>">
							</script>
					<?php
						}
					?>
					<input class='btn btn-info' value='<?php echo $a094;?>' name='captchanext' type='submit'>
					<input type="hidden" name="hash1" value="<?php echo $D_hash1;?>">
					<input type="hidden" name="hash2" value="<?php echo $D_hash2;?>">
					<?php if(isset($_POST['pass'])) {?><input type="hidden" name="pass" value="<?php echo $pass;?>"><?php } ?>
					<input type="hidden" name="STEP1" value="yes">
					<input type="hidden" name="STEP2" value="yes">
					<input type="hidden" name="STEP3" value="yes">
				</form>
						</center>
				</form>
			</div>
        </div>
      </div>
    </div>
			<?php
		}else {
			?>
		<form method='post' name='frm'>
			<input type="hidden" name="STEP1" value="yes">
			<input type="hidden" name="STEP2" value="yes">
			<input type="hidden" name="hash1" value="<?php echo $D_hash1;?>">
		</form>
		<script language="JavaScript">
			document.frm.submit();
		</script>
		<?php
		}
	}
	}
}
if(empty($_POST['STEP1']))  {
	if(isset($_POST['error'])){
		echo $_POST['error'];
	}
	if(!empty($LINK_password)) {
		//INPUT PASSWORD >> WITH HASH1
		?>
		<div style="padding: 120px 40px 0px" class="row">
      <div class="col-md-8 col-md-offset-2">
		<div class="row">
			<div class="col-md-8 col-md-offset-2">
				<form name="frm" id="password" action="" method="POST">
						<center>
						<div class="form-group has-success">
							<div class="input-group">
               			<span class="input-group-addon">Password:</span>
               			<input class="form-control" placeholder="This link is secured by password." name="pass" type="text">
       				  	</div>
						</div>
						<input class='btn btn-info' value='<?php echo $a094;?>' name='nextstep' type='submit'>
						<input type="hidden" name="hash1" value="<?php echo $D_hash1; ?>">
						<input type="hidden" name="STEP1" value="yes">
						<input type="hidden" name="STEP2" value="yes">
						</center>
				</form>
			</div>
        </div>
      </div>
    </div>
		<?php
	}else{
		?>
		<form method='post' name='frm'>
			<input type="hidden" name="STEP1" value="yes">
			<input type="hidden" name="STEP2" value="yes">
			<input type="hidden" name="hash1" value="<?php echo $D_hash1;?>">
		</form>
		<script language="JavaScript">
			document.frm.submit();
		</script>
		<?php
	}
}
?>
</div>
<?php
// FOOTER FOR HOMEPGAGE
if($LINK_adtype == 'video') {
	?>
		<script type="text/javascript" src="<?php echo $mainurl?>system/general/components/videoplayer/jwplayer.js"></script>
		<script type="text/javascript">
jwplayer.key="N8zhkmYvvRwOhz4aTGkySoEri4x+9pQwR7GHIQ==";

jwplayer("container1").setup({
  file: "<?php echo $AD_mediaurl; ?>",
  wmode: "transparent",
  screencolor: "1CAFFF",
  controls: "false",
  autostart: true,
  primary: "html",
  width: "100%",
  height: "640px"
});
 
function Forever(){
   if (innerWidth > innerHeight) {
   	document.getElementById("top_navbar").setAttribute("style","width:100%;margin: 0px;");
   }
   if (innerHeight > innerWidth) {
   	document.getElementById("top_navbar").setAttribute("style","width:100%;margin: 0px;");
   }
   document.getElementById("fullweb").setAttribute("style","padding: 0px;max-height: 100%");
   	document.getElementById("container1").setAttribute("style","width: 100%; background-color: #2B3E50; opacity: 1; height: " + innerHeight + "px;");
   $(window).resize(function() {
    	var $height = $(document).height();
    	jwplayer().resize("100%",$height);
	});
}

window.setInterval(function(){
  Forever();
}, 1000);

var controlfirst = 0;
var duration = 0;
var skip = 0;
var did = 0;
var rotate = 0;
jwplayer().onTime(function(event) {
  var remaining = Math.round(event.duration-event.position);
  if (controlfirst < 1) {
	duration = remaining;
  }
  controlfirst++;
  if (duration > <?php echo $sa['viddur'];?>){
	  var skiptime = <?php echo $sa['viddur'];?>;
  }else{
	  var skiptime = duration-1;
  }
  var Continuea = document.getElementById("areav5");
  var BVideo = document.getElementById("buttonv");
  skip = (duration - remaining);
  skiptext = (skiptime - skip);
  if (rotate == 0) {
	BVideo.innerHTML = '<i class="fa fa-circle-o-notch"></i> '+skiptext+' <?php echo $a036;?>';
	rotate = 1;
  }else if (rotate == 1) {
	BVideo.innerHTML = '<i class="fa fa-circle-o-notch fa-rotate-90"></i> '+skiptext+' <?php echo $a036;?>';
	rotate = 2;
  }else if (rotate == 2) {
	BVideo.innerHTML = '<i class="fa fa-circle-o-notch fa-rotate-180"></i> '+skiptext+' <?php echo $a036;?>';
	rotate = 3;
  }else if (rotate == 3) {
	BVideo.innerHTML = '<i class="fa fa-circle-o-notch fa-rotate-270"></i> '+skiptext+' <?php echo $a036;?>';
	rotate = 0;
  }
  if (skip > skiptime) {
  		Continuea.innerHTML = '<button onclick="javascript:document.frmvideo.submit();" id="buttonv" style="position: fixed; width: 30%; max-width: 30%; padding: 10px; bottom: 0px; left: 35%;" class="btn btn-success"><i class="fa fa-angle-double-right"></i> Continue</button>';
		if (did == 0) {
			<?php
			if ($sa['autocontinue'] == '1') {
			?>
				manualfunc();
  				$('#skipmodal').modal('show');
  				did = 1;
  			<?php
			}
			?>		
		}
	}
		
  	
});

window.onPause = function () {
  var progress = document.getElementById("progress");
  progress.value = "Paused";
}; 

var vis = (function(){
	var stateKey, eventKey, keys = {
		hidden: "visibilitychange",
		webkitHidden: "webkitvisibilitychange",
		mozHidden: "mozvisibilitychange",
		msHidden: "msvisibilitychange"
	};
	for (stateKey in keys) {
		if (stateKey in document) {
			eventKey = keys[stateKey];
			break;
		}
	}
	return function(c) {
		if (c) document.addEventListener(eventKey, c);
		return !document[stateKey];
	}
})();

vis(function(){
	document.title = vis() ? 'Ready' : 'Paused';
});

// to set the initial state
document.title = vis() ? 'Ready' : 'Paused';

var t=setInterval(runFunction,200);
var manualpush = 0;

function manualfunc() {
	if (jwplayer().getState() === 'PAUSED') {//PLAY
		jwplayer().play();
		manualpush = 0;
	}else if (jwplayer().getState() === 'BUFFERING') {//PLAY
		jwplayer().play();
		manualpush = 0;
	}else if (jwplayer().getState() === 'IDLE') {//PLAY
		jwplayer().play();
		manualpush = 0;
	}else if (jwplayer().getState() === 'PLAYING') {//PAUSE
		jwplayer().play();
		manualpush = 1;
	}
}

function setmute() {
	if (jwplayer().getMute() === true) {//NO SOUND - MUTED
		jwplayer().setMute(false);
	}else if (jwplayer().getMute() === false) {//SOUND - UNMUTED
		jwplayer().setMute(true);
	}
}

function continuewatching() {
	$('#skipmodal').modal('hide');
	manualfunc();
}

function runFunction() {
	if (jwplayer().getState() === 'BUFFERING') {//PLAY
		jwplayer().play();
	}
	if (document.title === 'Ready') {
		if (jwplayer().getState() === 'PAUSED') {//PLAY
			if (manualpush === 0) {
				jwplayer().play();
			}
		}else if (jwplayer().getState() === 'IDLE') {//PLAY
			jwplayer().play();
		}
	} else if (document.title === 'Paused') {//PAUSE
		if (jwplayer().getState() === 'PLAYING') {
				jwplayer().play();
		}
	}
	
	if (jwplayer().getMute() === true) {//NO SOUND - MUTED
		document.getElementById('muteButton').innerHTML='<i class="fa fa-volume-off"></i> Unmute';
	}else if (jwplayer().getMute() === false) {//SOUND - UNMUTED
		document.getElementById('muteButton').innerHTML='<i class="fa fa-volume-up"></i> Mute';
	}
	
	if (jwplayer().getState() === 'PAUSED') {//PAUSED
		document.getElementById('PlayPauseButton').innerHTML='<i class="fa fa-play"></i>';
	}else if (jwplayer().getState() === 'IDLE') {//IDLE
		document.getElementById('PlayPauseButton').innerHTML='<i class="fa fa-play"></i>';
	}else if (jwplayer().getState() === 'PLAYING') {//PLAYING
		document.getElementById('PlayPauseButton').innerHTML='<i class="fa fa-pause"></i>';
	}
}

		</script>
	<?php
}
include('other_footer.php');
?>
