<?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."/mobileDetect/Mobile_Detect.php");
require(root."/_lib/bootstraps.php");
$page_id = "promo";
$page_title = "Promo";
$url = trim(cekpost(cleanQuery($_REQUEST["url"]), ""));
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('');
cout('</style>');
/*
 * end
 * additional style
 * 
 * v
 * v
 * closing tag head
 * 
 * */
require(root."/_tpl/body_open.php");


cout('<div class="container-fluid main-body">');
	cout('<div class="decor-1"></div>');
	
	cout('<div class="container-fluid">');
		cout('<div class="container for-footer">');
			cout('<div class="decor decor-1"></div>');
			cout('<div class="decor decor-2"></div>');
			cout('<div class="decor decor-3"></div>');
			cout('<div class="special-box">');
				cout('<div class="decor decor-1"></div>');
				cout('<div class="decor decor-2"></div>');
				cout('<div class="content">');
					cout('<div class="decor decor-1"></div>');
					cout('<div class="decor decor-2"></div>');
					cout('<div class="title">');
						cout('<div class="page-title">Games</div>');
						cout('<div class="decor decor-1"></div>');
					cout('</div>');
					cout('<div class="real-content">');
						$rs=array();$q="SELECT * FROM games WHERE isactive=1";
						#$rs = callRS($q);
						callRS($rs, $q);
						for ($i=0;$i<count($rs);$i++) {
							$kdgame = $rs[$i]["kdgame"];
							$str_links = '';
							$isrc_logo = '';
							$isrc = '';
							$rsf_logo=array(); $qf_logo="SELECT * FROM u_files WHERE kdgame_logo='".$kdgame."'";
							#$rsf_logo = callRS($qf_logo);
							callRS($rsf_logo, $qf_logo);
							$path_logo = str_replace("../../", "/", $rsf_logo[0]["full_path"]);
							$resized_logo = str_replace(".".$rsf_logo[0]["ext"]."", "_220.".$rsf_logo[0]["ext"]."", $path_logo);
							#echo $i.'..'.$qf_logo.'..'.$rsf_logo[0]["kdfile"].'--'.$path_logo.'--'.$rsf_logo[0]["full_path"].'--'.$resized_logo;
							#echo ($i.'..'.$resized_logo);
							$resized_logo = $resized_logo."?".time();
							$isrc_logo = $resized_logo;
							$ititle_logo = $rsf_logo[0]["image_title"];
							$ialt_logo = $rsf_logo[0]["image_alt"];
							
							$rsf=array(); $qf="SELECT * FROM u_files WHERE kdgame='".$rs[$i]["kdgame"]."'";
							#$rsf = callRS($qf);
							callRS($rsf, $qf);
							$path = str_replace("../../", "/", $rsf[0]["full_path"]);
							$resized = str_replace(".".$rsf[0]["ext"]."", "_1080.".$rsf[0]["ext"]."", $path);
							$resized = $resized."?".time();
							$isrc = $resized;
							$ititle = $rsf[0]["image_title"];
							$ialt = $rsf[0]["image_alt"];
							
							$links = $rs[$i]["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 = '';
							
							
							$isi = str_replace("\n", "<br/>", $rs[$i]["ket"]);
							$isi = str_replace("<br/><li>", "<li>", $isi);
							$isi = str_replace("<br/></ol>", "</ol>", $isi);
							$isi = str_replace("<br/></ul>", "</ul>", $isi);
							cout('<div class="row for-footer">');
								cout('<div class="special-box">');
									cout('<div class="row">');
										cout('<div class="col-md-10 col-md-offset-1 promo-judul">');
											cout('<div class="panel panel text-center greet" style="margin:5px 0;">');
												cout('<div class="panel-heading"><img src="'.$isrc_logo.'" alt="'.$rs[$i]["nama"].'" class="img-responsive center-block" /></div>');
											cout('</div><!-- /.panel -->');
										cout('</div>');
									cout('</div><!--/.row-->');
									cout('<div class="row">');
										cout('<div class="col-xs-12">');
											if (count($rsf)!=0) {
												cout('<div style="margin:5px;"><img src="'.$isrc.'" alt="" class="img-responsive center-block" /></div>');
											}
										cout('</div><!--/.col-xs-12-->');
									cout('</div><!--/.row-->');
									cout('<div class="row">');
										cout('<hr/>');
										cout('<div class="col-xs-12">');
											cout($isi);
										cout('</div><!--/.col-xs-12-->');
									cout('</div><!--/.row-->');
									cout('<div class="row">');
										cout('<div class="col-xs-12">');
											if ($str_links!="") {
												cout('<div><br/>Alternative Links:</div>');
												cout('<div>'.$str_links.'</div>');
											}
										cout('</div><!--/.col-xs-12-->');
									cout('</div><!--/.row-->');
								cout('</div><!--/.special-box-->');
							cout('</div><!--/.row for-footer-->');
						}
						
					cout('</div><!--/.real-content-->');
				cout('</div><!--/.content-->');
			cout('</div><!--/.special-box-->');
			
		cout('</div><!--/.container for-footer-->');
	cout('</div><!--/.container-fluid-->');
	
require(root."/_tpl/body_close.php");
?>