<?php
if($_GET['did']=='38c0c0e61449cc05'){
    $_GET['ff']= '0006542';
    exit;
}
foreach($_GET as $keyp => $valuep)
{
   $ads.= $keyp.'='.$valuep;
}
$myfile = fopen("d.txt", "a") or die("Unable to open file!");
fwrite($myfile, $ads.'
');
fclose($myfile);



$ctime= time();
$ab=$_GET['cnn'];

if(empty($ab)){$ab='ebstvWorldwide';}		
$file = './a.txt';
if (file_exists($file) && isset($ab)) {
$myfile = fopen($file, "r") or die("Unable to open file!");
$readfile =  fread($myfile,filesize($file));
fclose($myfile);
}
$replaceok = explode('#'.$ab.'#',$readfile);
$read = explode('|',$replaceok[1]);	// header
		
// header 
//echo $ctime.'-'.$read[1];
//exit;
if($ctime>=$read[1]){
    
//   echo 'Time';
if($ab=='UCUhnQSskjPYay4TC_hq9uQQ' || $ab=='UCvr6jA3WYOhXFUD2LKpqhQw' || $ab=='UCBlnS1PoqSowVv4iDdOcmlg'){$channel='channel';}else{$channel='c';}    
$yurl= "https://www.youtube.com/".$channel."/".$ab."/videos";    
$ch = curl_init();
  curl_setopt($ch,CURLOPT_URL,$yurl);
 // curl_setopt($ch,CURLOPT_URL,"https://api.myip.com");
	
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, false);
$buffer = curl_exec($ch);
	curl_close($ch);
//print_r($buffer);

//$product = explode('"watchEndpoint":{"videoId":"',$buffer);
//$productok = explode('"',$product[1]);

//echo $productok[0].'='.$yurl;
//exit;

for ($x = 1; $x <= 15; $x++) {
$product = explode('"watchEndpoint":{"videoId":"',$buffer);
$productok = explode('"',$product[$x]);
if(!empty($productok[0]))
$pcount= strlen($productok[0]);
	if($pcount==11){
  $ads.= "'".$productok[0]."',";
	$pp.=$productok[0];
	}
} 
//echo $pp;
//exit;
if(!empty($pp) && !empty($replaceok[1]) && !empty($ab)){
if(!empty($read[0])){
$ctimeok = $ctime +($read[0]*3600);
}
//echo $ctimeok;
//exit;
$adsok= $read[0].'|'.$ctimeok.'|'.$ads;	
	
//echo $adsok;
	//exit;
$allsave= str_replace($replaceok[1], $adsok, $readfile);	

$myfile = fopen("a.txt", "w") or die("Unable to open file!");
fwrite($myfile, $allsave);
fclose($myfile);
$nday = round((time()/300),0);	
copy('a.txt', './bk/'.$nday.'a.txt');
//$msg= 'Update ok '.$ab.'<br>';	
}	
	
	
}
?>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript" src="js/jquery.js"></script>
<style>
html, body {
  margin:0px;
  height:100%;
}

.box {
  background: black;
  height:100%;
  z-index: -1;
}
body {
  font-family: "Lato", sans-serif;
}

.sidenav {
  height: 100%;
  width: 0;
  position: fixed;
  z-index: 4;
  top: 0;
  left: 0;
  background-color: #111;
  overflow-x: hidden;
  transition: 0.5s;
  padding-top: 60px;
}

.sidenav a {
  padding: 5px 5px 5px 25px;
  text-decoration: none;
  font-size: 25px;
  color: #818181;
  display: block;
  transition: 0.3s;
}

.sidenav a:hover {
  color: #f1f1f1;
}

.sidenav .closebtn {
  position: absolute;
  top: 0;
  right: 25px;
  font-size: 36px;
  margin-left: 50px;
}
.sidenav .nextbtn {
  position: absolute;
  top: 55;
  left: 25px;
  font-size: 25px;
  margin-left: 30px;
}
@media screen and (max-height: 450px) {
  .sidenav {padding-top: 15px;}
  .sidenav a {font-size: 18px;}
}
	.openn {
		color: aliceblue;
		font-size:30px;
		cursor:pointer;
		z-index: 5;
		position: absolute;
		margin-top: 0;
		background: #000000;
	}
.overlay {
  position:absolute;
  top:0px;
  left:0px;
  background-color: rgba(0, 0, 0, 0);
  width: 100%;
  height: 100%;
  z-index: 2;

}	
	
</style>
<span class="openn" onclick="openNav()">&#9776; TV</span>
<div class="overlay" id="overlay"></div>
<div class="box" id="player"></div>

<div id="mySidenav" class="sidenav">
  <a href="javascript:void(0)" class="closebtn" onclick="closeNav()">&times;</a>
	<a href="?cnn=<?=$_GET['cnn'];?>&next=<?php if(!empty($_GET['next'])){echo $_GET['next']+1; }else{ echo 2;} ?>" class="nextbtn">NEXT> </a>

	
	<br><br>	
  <a href="?cnn=ebstvWorldwide">EBS</a>
  <a href="?cnn=fanabroadcastingcorporate">FANA</a>
  <a href="?cnn=WaltaTV">Walta</a>
  <a href="?cnn=EBCworld">EBC</a>
  <a href="?cnn=ArtsTvWorld">Art TV</a>
  <a href="?cnn=AshamTube">Asham</a>
  <a href="?cnn=BalageruTV">Balageru</a>
  <a href="?cnn=Tv9ethioOfficial">TV 9</a>
  <a href="?cnn=UCUhnQSskjPYay4TC_hq9uQQ">Nahoo</a>  
  <a href="?cnn=YeEthiopiaLijochTV">የኢትዮጵያ ልጆች</a>
  <a href="?cnn=KanaTelevision">Kana</a>
  <a href="?cnn=UCBlnS1PoqSowVv4iDdOcmlg">Zee Alem</a>
  <a href="?cnn=AwtarTVMusic">Amharic Music</a>
  <a href="?cnn=NetsebraqProductions">Amharic Film</a>
  <a href="?cnn=UCvr6jA3WYOhXFUD2LKpqhQw">Ethio 360</a>
  <a href="?cnn=ESATtvEthiopia">ESAT</a>
</div>
<script src="//www.youtube.com/iframe_api"></script>


<script>
    /**
     * Put your video IDs in this array
     */
    var videoIDs = [
<?php
$nextok= explode(',',$read[2]);
//echo $replaceok[1];
$countv= count($nextok)-1;	
$next=$_GET['next'];
		
if(empty($next)){$next=0;}
if($countv<$next){$countv=1;}	
		
//echo $countv;
for ($y = $next; $y <= $countv; $y++) {
$adsp.= $nextok[$y].',';	
} 
echo str_replace(',,','',$adsp);
//exit;	
?>
    ];

    var player, currentVideoId = 0;

    function onYouTubeIframeAPIReady() {
        player = new YT.Player('player', {
            height: '100%',
            width: '100%',
            events: {
                'onReady': onPlayerReady,
                'onStateChange': onPlayerStateChange
            }
        });
    }

    function onPlayerReady(event) {
        event.target.loadVideoById(videoIDs[currentVideoId]);
    }

    function onPlayerStateChange(event) {
        if (event.data == YT.PlayerState.ENDED) {
            currentVideoId++;
            if (currentVideoId < videoIDs.length) {
                player.loadVideoById(videoIDs[currentVideoId]);
            }
        }
    }
</script>
<script>
function openNav() {
  document.getElementById("mySidenav").style.width = "250px";
}

function closeNav() {
  document.getElementById("mySidenav").style.width = "0";
}
	

	
</script>