<?php 
error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING ^ E_DEPRECATED ^ E_STRICT); 
$rootPath = is_file("../../../../library/document.php") ? "../../../../" : "../../";
define("CMS", "korCMS");
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https" : "http";
include($rootPath."config/odyssey.ini.php");
include($rootPath."library/messages.php");
include($rootPath."library/db.php");
include($rootPath."library/system.php");
include($rootPath."library/variables.php");
include($rootPath."library/language.php");
include($rootPath."library/parameters.php");
include($rootPath."library/content.php");

$db = new db();
$db->query("SET NAMES 'utf8mb4'");
$system = new system();
$messages = new messages();
$variables = new variables();
$language = new language();
$parameters = new parameters();
$content = new content();


$langID = ($_GET['langID']) ? (int)$_GET['langID'] : $language->getDefaultLanguage();
$variables->getSafeVars(array_keys($_REQUEST));

function getFPath(){
	$parts = explode("/", $_SERVER["PHP_SELF"]);
	array_shift($parts); // the first element will be empty to we get rid of it
	array_pop($parts); // get rid of script name
	$fPath =implode("/", $parts);
	if(substr($fPath, -1) != "/") $fPath.="/";
	$fPath = ($fPath == "/") ? null : $fPath;	
	return $fPath;	
}

?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="<?php echo $rootPath;?>admin/css/admin.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="<?php echo $rootPath;?>js/jquery.js"></script>
<script type="text/javascript" src="<?php echo $rootPath;?>admin/js/admin.js"></script>
<script type="text/javascript" src="<?php echo $rootPath;?>js/html5gallery.js"></script>
<style  type="text/css">
<!--
body {
	margin:0 auto;
	overflow: hidden;
	background: #000000;
	max-width:620px;
	font-family: Verdana, sans-serif, Arial;
	font-size:11px;	
}
-->
</style>
</head>
<body>
<!-- A wrapper DIV to center the Gallery -->
<div style="text-align:center;">
<?php
$query = "SELECT distinct videos.*, content_videos.title FROM videos, content_videos WHERE videos.linkID='$linkID' and videos.sectionID='$sectionID' and content_videos.mainID=videos.id and content_videos.langID='$langID' order by videos.id desc";
$records=$db->getRecords($query);
if(!count($records)){
	?>
	<script>
	parent.$.fancybox.close();
	</script>
	<?php
}else{
?>
	<div style="display:none;margin:0 auto;" class="html5gallery" data-responsive="true" fullscreen="true" data-skin="dark" data-thumbwidth="130" data-thumbheight="80">
	<?php
	foreach($records as $record){
		$videoProvider = $record->provider;
		$videoCode = $record->videoCode;
		$videoURL = $content->getVideoURL($videoProvider, $videoCode);
		$videoThumb = $content->getVideoThumb($videoProvider, $videoCode);
	?>
	<a href="<?php echo $videoURL;?>"><img src="<?php echo$videoThumb;?>" alt="<?php echo $record->title;?>"></a>
	<?php
	}
	?>
	</div>
<?php
}
?>
</div>
</body>
</html>
