<?php
	$file = "";
	if ( isset($_GET['f']) && $_GET['f'] != "" ) {
		$file = $_GET['f'];
	} 
	$file = str_replace("http://","https://",$file);
	
	$isGeo = "false";
	if ( isset($_GET['geo']) && $_GET['geo'] != "" ) {
		$isGeo = $_GET['geo'];
	}

	$country = "GR";
	if ( isset($_GET['cn']) && $_GET['cn'] != "" ) {
		$country = $_GET['cn'];
	}

	$bgImg = "";
	if ( isset($_GET['bgimg']) && $_GET['bgimg'] != "" ) {
		$bgImg = str_replace("http://","https://",$_GET['bgimg']);
		//$bgImg = $_GET['bgimg'];
	}
	
		
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
   <meta charset="utf-8">
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
   <script src="https://static.adman.gr/adman.js"></script>
   <script src="https://player.pstatic.gr/phaistos-player/phaistosplayer.js?t=20240109_0130"></script>
  <!--<script language="JavaScript" type="text/javascript" src="https://code.jquery.com/jquery-2.2.3.min.js"></script>-->
  <script language="JavaScript" type="text/javascript" src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<style>
.bmpui-ui-watermark {
background-image: url('https://archive.ert.gr/wp-content/uploads/2020/10/ERT-Arxeio-logo-new-white_250x54.png') !important;
width: 250px !important;
height: 200px !important;
display: block!important;
pointer-events:none!important;
opacity: 0.2!important;
}
</style>
   </head>
<body>
<div id="container"></div>
<script type="text/javascript">
	var HLSLink = 'https://mediastream.ert.gr/vodedge/_definst_/mp4:archive/<?php echo $file;?>/playlist.m3u8'
	var title ='Greece - WorldWide';
	var isGeo =  "<?php echo $isGeo;?>";
	var country =  "<?php echo $country;?>";
	$.ajaxSetup({ timeout: 2000 });

	function playerSetup() {
		var conf = {
		   configuration: {
			adman: {
			       	videoplayer_endpoint_hostname: 'ert.adman.gr',
			       	videplayer_pubid: 'K:rKqQ5bhsSsb:j3fMwsBwoTc',
			       	type: 'onDemand',          
			},
		   	playback: {
				autoplay                : false,
			   	playsInline             : false,
		   		muted                   : false
		   	},
		   	poster: "<?php echo $bgImg;?>",		  
		   	source: [{
			  	name: 'Archive',
		  		type:'hls',
		      		url: HLSLink  
		  	}],
		  	requestPictureInPicture: true,
		  	style : {
		    		width       : '100%',
		    		aspectratio : '16:9',
		    		ux    : true
		   	}  	 
		}};
	 	var phPl = new PhaistosPlayer('container',conf);	
	}

	if (isGeo == "true") {
		$.getJSON('https://geoip.siliconweb.com/geo.json', function (response) {
			HLSLink = 'https://mediastream.ert.gr/vodedge/_definst_/mp4:dvrorigingr/<?php echo $file;?>/playlist.m3u8';
			if(country.includes(response.country))
			{
				HLSLink = 'https://mediastream.ert.gr/vodedge/_definst_/mp4:dvrorigingr/<?php echo $file;?>/playlist.m3u8';
				title = 'Greece';
			}
			else
			{	
				HLSLink = 'https://mediastream.ert.gr/vodedge/_definst_/mp4:archive/copyright-alert.mp4/playlist.m3u8';
				title = 'WorldWide';  
			}
		}).fail(function() {
			console.log( "error" );
		})
		.always(function() {
			playerSetup() ;
		});
	}else{
		playerSetup() ;
	}	

</script>
</body>
</html>
