<?php
if (!defined("root")) {
	define("root", $_SERVER['DOCUMENT_ROOT']);
}
session_start();
require(root."/_common.php");
require(root."/_lib/db.php");
require(root."/_lib/main.php");
require(root."/_lib/bootstraps.php");
$a = cekpost(cleanQuery(isset($_GET["a"])?$_GET["a"]:""), "");
$b = cekpost(cleanQuery(isset($_GET["b"])?$_GET["b"]:""), "");
$c = cekpost(cleanQuery(isset($_GET["c"])?$_GET["c"]:""), "");
$page_id = strtolower($b);
if ($a=="game-categories") {
	switch(strtolower($b)) {
		case "live-casino": 	{ $page_title = "Live Casino";	break; }
		case "sportsbook": 		{ $page_title = "Sportsbook";	break; }
		case "slot-games": 		{ $page_title = "Slot Games";	break; }
		case "poker": 			{ $page_title = "Poker";		break; }
		case "promotions": 		{ $page_title = "Promotions";	break; }
		case "transactions": 	{ $page_title = "Transactions";	break; }
		case "blog": 			{ $page_title = "Blog";			break; }
	}
}

require(root."/_tpl/html_begin.php");
require(root."/_tpl/tag_head.php");
#require(root."/_tpl/ie_style_exception.php");
/*
* begin
* additional style
* */
cout('<style type="text/css">');
cout('.pointer {');
	  cout('cursor: pointer;');
  cout('}');
cout('</style>');
/*
* end
* additional style
* 
* v
* v
* closing tag head
* 
* */
require(root."/_tpl/body_open.php");
cout('<div class="container-fluid common-page">');
	if ($a=="game-categories") {
		$rsgc=array();$qgc="SELECT a.* FROM game_cats a WHERE url='$b' AND a.isactive=1";
		callRS($rsgc, $qgc);
		$rsi=array(); $qi="SELECT * FROM u_files WHERE kdgame_cat='".$rsgc[0]["kdgame_cat"]."'";
		callRS($rsi, $qi);
		$path = (count($rsi)!=0)?str_replace("../../", "/", $rsi[0]["full_path"]):'';
		$resized = (count($rsi)!=0)?str_replace(".".$rsi[0]["file_ext"]."", "_1900.".$rsi[0]["file_ext"]."", $path):'';
		
		if ($c=="") {
			cout('<div class="page-slideshow-container">');
				cout('<div class="page-slideshow call-bg-'.strtolower($rsgc[0]["url"]).'">
					<img src="'.$resized.'" class="img-responsive" alt=""/>
				</div>');
			cout('</div><!--/.page-slideshow-container-->');
		} else {
			$rsg=array();$qg="SELECT a.* FROM games a LEFT JOIN game_cats b ON b.kdgame_cat=a.kdgame_cat LEFT JOIN negara c ON c.kdnegara=a.kdnegara WHERE b.url='$b' AND a.isactive=1 AND (a.kdnegara=0 OR c.kdlang='".$_SESSION["lang_id"]."') AND a.url='".$c."'";
			callRS($rsg, $qg);
			
			$rsss=array(); $qss="SELECT * FROM u_files WHERE kdgame='".$rsg[0]["kdgame"]."'";
			callRS($rsss, $qss);
			$path_ss = (count($rsss)!=0)?str_replace("../../", "/", isset($rsss[0]["full_path"])?$rsss[0]["full_path"]:''):'';
			$resized_ss = (count($rsss)!=0)?str_replace(".".(isset($rsss[0]["file_ext"])?$rsss[0]["file_ext"]:'')."", "_1080.".(isset($rsss[0]["file_ext"])?$rsss[0]["file_ext"]:'')."", $path_ss):'';
			
			$rsgirl=array(); $qgirl="SELECT * FROM u_files WHERE kdgame_girl='".$rsg[0]["kdgame"]."'";
			callRS($rsgirl, $qgirl);
			$path_girl = (count($rsgirl)!=0)?str_replace("../../", "/", isset($rsgirl[0]["full_path"])?$rsgirl[0]["full_path"]:''):'';
			$resized_girl = (count($rsgirl)!=0)?str_replace(".".(isset($rsgirl[0]["file_ext"])?$rsgirl[0]["file_ext"]:'')."", "_500.".(isset($rsgirl[0]["file_ext"])?$rsgirl[0]["file_ext"]:'')."", $path_girl):'';
			
			$rslogo=array(); $qlogo="SELECT * FROM u_files WHERE kdgame_logo='".$rsg[0]["kdgame"]."'";
			callRS($rslogo, $qlogo);
			$path_logo = (count($rslogo)!=0)?str_replace("../../", "/", isset($rslogo[0]["full_path"])?$rslogo[0]["full_path"]:''):'';
			$resized_logo = (count($rslogo)!=0)?str_replace(".".(isset($rslogo[0]["file_ext"])?$rslogo[0]["file_ext"]:'')."", "_220.".(isset($rslogo[0]["file_ext"])?$rslogo[0]["file_ext"]:'')."", $path_logo):'';
			
			cout('<div class="page-slideshow-container slideshow-specific">');
				cout('<div class="page-slideshow opa-bg call-bg-'.strtolower($rsgc[0]["url"]).'">
					<!--<img src="'.$resized.'" class="for-opa-bg img-responsive" alt=""/>-->
					<img src="'.$resized_ss.'" class="for-ani-img for-ani-img-ss img-responsive" alt=""/>
					<img src="'.$resized_girl.'" class="for-ani-img for-ani-img-girl img-responsive" alt=""/>
					<img src="'.$resized_logo.'" class="for-ani-img for-ani-img-logo img-responsive" alt="'.$rsg[0]["nama"].'"/>
					<div class="for-ani-img for-ani-tool">a</div>
				</div>');
			cout('</div><!--/.page-slideshow-container-->');
		}
	}
	
	cout('<div class="container-custom-fluid game-lists">');
		if ($a=="game-categories") {
			if ($c!="") {
				$rsg=array();$qg="SELECT a.* FROM games a LEFT JOIN game_cats b ON b.kdgame_cat=a.kdgame_cat LEFT JOIN negara c ON c.kdnegara=a.kdnegara WHERE b.url='$b' AND a.isactive=1 AND (a.kdnegara=0 OR c.kdlang='".$_SESSION["lang_id"]."') AND a.url='".$c."'";
				callRS($rsg, $qg);
				$rsi=array(); $qi="SELECT * FROM u_files WHERE kdgame='".$rsg[0]["kdgame"]."'";
				callRS($rsi, $qi);
				$path = (count($rsi)!=0)?str_replace("../../", "/", $rsi[0]["full_path"]):'';
				$resized = (count($rsi)!=0)?str_replace(".".$rsi[0]["file_ext"]."", "_1080.".$rsi[0]["file_ext"]."", $path):'';
				cout('<div class="row">');
					cout('<div class="col-md-8">');
						cout('<div class="game-lists">');
							cout('<div class="game-nama2">'.$rsg[0]["nama"].'</div>');
							#cout('<div class="game-img"><img src="'.$resized.'" class="img-responsive" /></div>');
							$ket = json_decode($rsg[0]["ket"], 1);
							$t_isi_ket = $ket[$_SESSION["lang_id"]];
							$t_isi_ket = str_replace('(loik/enter)', "<br/>", $t_isi_ket);
							$t_isi_ket = str_replace('(loik/slash)', "'", $t_isi_ket);
							$t_isi_ket = str_replace('(loik/doubleslash)', '"', $t_isi_ket);
							cout('<div class="game-ket">'.$t_isi_ket.'</div>');
							#cout('<div><a class="game-readmore" href="#" onclick="return false;">Read More</a></div>');
						cout('</div>');
					cout('</div><!--/.col-md-8-->');
					cout('<div class="col-md-4">');
						cout('<div class="game-img"><img src="'.$resized.'" class="img-responsive" /></div>');
					cout('</div><!--/.col-md-4-->');
				cout('</div><!--/.row-->');
				#printR($rsg);
			} else {
				$rsg=array();$qg="SELECT a.*, b.url AS url_cat FROM games a LEFT JOIN game_cats b ON b.kdgame_cat=a.kdgame_cat LEFT JOIN negara c ON c.kdnegara=a.kdnegara WHERE b.url='$b' AND a.isactive=1 AND (a.kdnegara=0 OR c.kdlang='".$_SESSION["lang_id"]."')";
				callRS($rsg, $qg);
				cout('<div class="owl-carousel">');
					for ($i=0;$i<count($rsg);$i++) {
						/*
						$rsi=array(); $qi="SELECT * FROM u_files WHERE kdgame='".$rsg[$i]["kdgame"]."'";
						callRS($rsi, $qi);
						$path = (count($rsi)!=0)?str_replace("../../", "/", $rsi[0]["full_path"]):'';
						$resized = (count($rsi)!=0)?str_replace(".".$rsi[0]["file_ext"]."", "_1080.".$rsi[0]["file_ext"]."", $path):'';
						*/
						$rsi=array(); $qi="SELECT * FROM u_files WHERE kdgame_girl='".$rsg[$i]["kdgame"]."'";
						callRS($rsi, $qi);
						$path = '';
						$resized = '';
						if (count($rsi)!=0) {
							$path = str_replace("../../", "/", (isset($rsi[0]["full_path"])?$rsi[0]["full_path"]:''));
							$resized = str_replace(".".(isset($rsi[0]["file_ext"])?$rsi[0]["file_ext"]:'')."", "_500.".(isset($rsi[0]["file_ext"])?$rsi[0]["file_ext"]:'')."", $path);
						}
						$rsil=array(); $qil="SELECT * FROM u_files WHERE kdgame_logo='".$rsg[$i]["kdgame"]."'";
						callRS($rsil, $qil);
						$pathl = '';
						$resizedl = '';
						if (count($rsi)!=0) {
							$pathl = (count($rsi)!=0)?str_replace("../../", "/", (isset($rsil[0]["full_path"])?$rsil[0]["full_path"]:'')):'';
							$resizedl = (count($rsil)!=0)?str_replace(".".(isset($rsil[0]["file_ext"])?$rsil[0]["file_ext"]:'')."", "_220.".(isset($rsil[0]["file_ext"])?$rsil[0]["file_ext"]:'')."", $pathl):'';
						}
						
						cout('<div class="item">');
							cout('<div class="game-img"><img src="'.$resized.'" width="220" class="img-responsivex center-block" /></div>');
							cout('<div class="text-center game-nama"><img src="'.$resizedl.'" alt="'.$rsg[$i]["nama"].'" /></div>');
							#cout('<div class="game-img"><img src="'.$resized.'" class="img-responsive" /></div>');
							#cout('<div class="game-nama">'.$rsg[$i]["nama"].'</div>');
							$sket = json_decode($rsg[$i]["short_ket"], 1);
							$t_isi_sket = $sket[$_SESSION["lang_id"]];
							$t_isi_sket = str_replace('(loik/enter)', "<br/>", $t_isi_sket);
							$t_isi_sket = str_replace('(loik/slash)', "'", $t_isi_sket);
							$t_isi_sket = str_replace('(loik/doubleslash)', '"', $t_isi_sket);
							cout('<div class="game-ket">'.$t_isi_sket.'</div>');
							cout('<div><a class="game-readmore" href="'.$rsg[$i]["url_cat"].'/'.$rsg[$i]["url"].'">Read More</a></div>');
						cout('</div>');
					}# end for ($i=0;$i<count($rsg);$i++)
				cout('</div><!--/.owl-carousel-->');
				cout('<script>');
					cout('$(window).load(function(){');
						cout('var containerWidth = $(".game-lists").width();');
						cout('$(".game-lists").css({ "width":containerWidth+"px" });');
						cout('setTimeout(function(){');
							cout('var owl = $(".owl-carousel");');
							cout('owl.owlCarousel({');
								cout('margin:10,');
								if (count($rsg)>4) {
									cout('loop:true,');
								} else {
									cout('items:'.count($rsg).',');
								}
								cout('autoplay:true,');
								cout('autoplayTimeout:4000,');
								cout('autoplayHoverPause:false,');
								cout('responsive:{');
									cout('0:{ items:1 },');
									cout('600:{ items:3 },');
									cout('1000:{ items:4 }');
								cout('}');
							cout('});');
						cout('}, 100);');
					cout('});');
				cout('</script>');
				
			} #end if ($c=="")
		}#end if ($a=="game-categories")
		
	cout('</div><!--/.container-custom-fluid game-lists-->');
	
		
cout('</div><!--/.container-fluid common-page-->');
require(root."/_tpl/body_close.php");
?>