<?php
if (!defined("root")) {
	define("root", $_SERVER['DOCUMENT_ROOT']);
}
ob_start();
require(root."/___simple_config.php");
session_start();
require(root."/_common.php");
require(root."/_lib/db.php");
require(root."/_lib/main.php");
require(root."/_lib/bootstraps.php");
$a = cekpost(cleanQuery($_GET["a"]), "");
if ($a=="changelang") {
	$lang = cekpost(cleanQuery($_GET["lang"]), "us");
	$_SESSION["lang"] = strtolower($lang);
	$rsl=array();$ql = "SELECT * FROM langs WHERE LOWER(kodelang)='".strtolower($lang)."';";
	callRS($rsl, $ql);
	$_SESSION["lang"] = strtolower($lang);
	$_SESSION["lang_id"] = $rsl[0]["kdlang"];
	echo $_SESSION["lang"];
}
if ($a=="getdetailgames") {
	$id = cekpost(cleanQuery($_GET["id"]), "");
	$rs=array(); $q="SELECT * FROM games WHERE isactive=1 AND kdgame='".$id."'";
	callRS($rs, $q);
	$links = $rs[0]["links"];
	$arr_links = explode(",", $links);
	$tmp_link = '';
	$cnt_links = 0;
	for ($j=0;$j<count($arr_links);$j++) {
		$tmp_link = trim($arr_links[$j]);
		if ($str_links!="") { $str_links .= ', '; }
		if ($tmp_link!="") {
			$str_links .= '<a href="//'.$tmp_link.'" target="_blank">'.$tmp_link.'</a>';
		}
	}
	$alt_links = '';
	if ($str_links!="") {
		$alt_links = '<hr/><div class="text-warning">Alternatif Links:</div>'.$str_links.'';
	}
	$rsi=array(); $qi="SELECT * FROM u_files WHERE kdgame='".$rs[0]["kdgame"]."'";
	callRS($rsi, $qi);
	$path = str_replace("../../", "/", $rsi[0]["full_path"]);
	$resized = str_replace(".".$rsi[0]["ext"]."", "_1080.".$rsi[0]["ext"]."", $path);
	$ss_img = $resized==""?'':'<img class="img-responsive" src="'.$resized.'" alt="" /><hr/>';
	
	$rsi=array(); $qi="SELECT * FROM u_files WHERE kdgame_logo='".$rs[0]["kdgame"]."'";
	callRS($rsi, $qi);
	$path = str_replace("../../", "/", $rsi[0]["full_path"]);
	$resized = str_replace(".".$rsi[0]["ext"]."", "_220.".$rsi[0]["ext"]."", $path);
	$logo_img = $resized==""?$rs[0]["nama"]:'<img src="'.$resized.'" alt="" />';
	
	$ket = str_replace("\n", '<br/>', $rs[0]["ket"]);
	$target = '';
	$target .= 'modal-title$$<div class="uppercase">'.$logo_img.'</div>';
	$target .= '$$$';
	$target .= 'modal-body$$<div class="container-fluid">'.$ss_img.''.$ket.''.$alt_links.'</div>';
	$target .= '$$$';
	$target .= 'modal-footer$$<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>';
	echo $target;
	
}
?>