<?php
$error = false;
if(isset($_GET['file'])) 
	$video = $_GET['file'];
else
	$error = true;
	
if(isset($_GET['type'])) {
	if(filter_var($_GET['type'], FILTER_VALIDATE_REGEXP, array('options'=>array('regexp'=>'/^[0-9]{1,2}$/i'))) !== FALSE)
		$type = $_GET['type'];
	else
		$error = true;
} else
	$type = 0;

if(isset($_GET['player'])) {
	$player = 'http://media.telecoms.com/jwplayer/player.swf';
}else{
	$player = 'http://media.telecoms.com/video_page/vPlayer.swf';
}

if($error) {
	echo 'URL has an error. Please check the URL.';
	exit();
}

switch($type) {
	case 0:
		$video = 'http://media.telecoms.com/cdn/'.$video;
		break;
	case 1:
		$video = 'http://cdn.informatm.com/videos/'.$video;
		break;
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>PLAY VIDEO</title>
<style>
	body {
		margin:10px auto; width:600px; background-color:#000; color:#fff; font-family:Arial, Helvetica, sans-serif;
		font-size:1em;
	}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="http://media.telecoms.com/jqueryplugins/jquery.swfobject.1-1-1.min.js"></script>
<script>
$(document).ready( function() {
	
});
</script>
</head>

<body>
<div id="wrapper">
	
<?php 
	if(strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone') === false && strpos($_SERVER['HTTP_USER_AGENT'], 'iPad') === false && strpos($_SERVER['HTTP_USER_AGENT'], 'iPod') === false) {
?>
	<div id="video_space">	
		<object width="600" height="400" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0">	
        	<param name="allowScriptAccess" value="always"/>
            <param name="allowFullScreen" value="true"/>
            <param name="movie" value="<?php echo $player;?>"/>
            <param name="quality" value="high"/>
            <param name="wmode" value="transparent"/>
            <param name="bgcolor" value="#000000"/>
            <param name="scale" value="noscale"/>
            <param name="salign" value="tl"/>
            <param name="FlashVars" value="file=<?php echo $video;?>&autoplay=true"/>
            <embed src="<?php echo $player;?>" quality="high" allowscriptaccess="always" allowfullscreen="true" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" width="600" height="400" scale="noscale" salign="tl" bgcolor="#000000" flashvars="file=<?php echo $video;?>&autoplay=true"/>
        </object>
    </div>
	<script>
		$("#video_space").flash({
			swf:"<?php echo $player;?>",
			width:600,
			height:400,
			allowScriptAccess:"samedomain",
			allowFullScreen:true,
			quality:"high",
			wmode:"transparent",
			scale:"noscale",
			salign:"tl",
			expressInstaller:"http://media.telecoms.com/jqueryplugins/expressInstall.swf",
			flashvars:{ file:"<?php echo $video;?>", autoplay:"true"}
		});
    </script>
<?php
	}else{
?>
	<video src="<?php echo $video;?>" width="600" height="400" controls="controls" autoplay="true">
    </video>
<?php
	}
?>
</div>
</body>
</html>