<?php
if (!defined("root")) {
	define("root", $_SERVER['DOCUMENT_ROOT']);
}
require(root."/___simple_config.php");
session_start();
$page_id = "daftar";
require(root."/".memberFolder."/_common.php");
require(root."/".memberFolder."/_lib/db.php");
require(root."/".memberFolder."/_lib/main.php");
require(root."/_lib/languages.php");
#require(root."/mobileDetect/Mobile_Detect.php");
require(root."/".memberFolder."/_lib/bootstraps.php");
$page_title = "Pendaftaran";
$page_id = "register";
$rand = cekpost(cleanQuery(isset($_REQUEST["rand"])?$_REQUEST["rand"]:""), "");
$kirim = cekpost(cleanQuery(isset($_REQUEST["kirim"])?$_REQUEST["kirim"]:""), "");
$err = array();
$ibank = "";
$igame = "";
$inorek = "";
$inamarek = "";
$iemail = "";
$itelp = "";
$ipass = "";
$ival = "";
if ($kirim==1) {
	$ibank = cekpost(cleanQuery($_REQUEST["ibank"]), "");
	$igame = cekpost(cleanQuery($_REQUEST["igame"]), "");
	$inorek = cekpost(cleanQuery($_REQUEST["inorek"]), "");
	$inamarek = cekpost(cleanQuery($_REQUEST["inamarek"]), "");
	$iemail = cekpost(cleanQuery($_REQUEST["iemail"]), "");
	$itelp = cekpost(cleanQuery($_REQUEST["itelp"]), "");
	$ipass = cekpost(cleanQuery($_REQUEST["ipass"]), "");
	$ival = cekpost(cleanQuery($_REQUEST["ival"]), "");
	if ($ibank=="") { $err["ibank"] = $lang[$_SESSION["lang"]]["form-alert-bank"]; }
	if ($igame=="") { $err["igame"] = $lang[$_SESSION["lang"]]["form-alert-games"]; }
	if ($inorek=="") { $err["inorek"] = $lang[$_SESSION["lang"]]["form-alert-norek"]; }
	if ($inamarek=="") { $err["inamarek"] = $lang[$_SESSION["lang"]]["form-alert-namarek"]; }
	if ($iemail=="") { $err["iemail"] = $lang[$_SESSION["lang"]]["form-alert-email"]; }
	if ($itelp=="") { $err["itelp"] = $lang[$_SESSION["lang"]]["form-alert-telp"]; }
	if ($ipass=="") { $err["ipass"] = $lang[$_SESSION["lang"]]["form-alert-pass-dash"]; }
	if ($ival=="") { $err["ival"] = $lang[$_SESSION["lang"]]["form-alert-valid"]; }
	if (!is_numeric($inorek) && $inorek!="") { $err["inorek"] = $lang[$_SESSION["lang"]]["form-alert-norek2"]; }
	if (!is_numeric($itelp) && $itelp!="") { $err["itelp"] = $lang[$_SESSION["lang"]]["form-alert-telp2"]; }
	if (!check_email_address($iemail) && $iemail!="") { $err["iemail"] = $lang[$_SESSION["lang"]]["form-alert-email2"]; }
	if ($ival!=$_SESSION["code"] && $ival!="") { $err["ival"] = $lang[$_SESSION["lang"]]["form-alert-valid2"]; }
	$rsc=array();$qc="SELECT * FROM members WHERE norek='$inorek' AND kdbank='$ibank' AND kdgame='$igame' AND isdeleted=0 AND isactive=1";
	#$rsc = callRS($qc);
	callRS($rsc, $qc);
	if (count($rsc)!=0) { $err["inorek"] = $lang[$_SESSION["lang"]]["form-alert-norek3"]; }
	if (empty($err)) {
		$isactive = 1;
		$creby = "VISITOR";
		$cretime = time();
		$kdmember = getID("members", "kdmember");
		#$tablename = "members";
		#$fieldname = "kdmember";
		#$rsGetID = callRS("SELECT MAX($fieldname) AS fieldID FROM $tablename");
		#$getID=(count($rsGetID)!=0 && $rsGetID[0]['fieldID']!=null) ?(intval($rsGetID[0]['fieldID'])+1):1;
		#$kdmember = $getID;
		#echo $kdmember;
		$tanggal_daftar = time();
		$kode_random = generateRandomString(15);
		$ip1 = get_client_ip();
		$ip2 = get_client_ip2();
		$ip3 = get_client_ip2();
		$session_id = session_id();
		do {
			$rscek = array(); $qcek = "SELECT kdmember FROM members WHERE kode_random = '$kode_random'";
			#$rscek = callRS($qcek);
			callRS($rscek, $qcek);
			if (count($rscek)!=0) {
				$flag = 0;
				$kode_random = generateRandomString(15);
			} else {
				$flag = 1;
			}
		} while($flag==0);
		$ipass = saltEncoding($ipass);
		$q = "INSERT INTO members (kdmember, kdgame, kdbank, norek, namarek, email, telp, pass, isactive, tanggal_daftar, kode_random, ip1, ip2, ip3, session_id, creby, cretime) 
			VALUES ('$kdmember', '$igame', '$ibank', '$inorek', '$inamarek', '$iemail', '$itelp', '$ipass', '$isactive', '$tanggal_daftar', '$kode_random', '$ip1', '$ip2', '$ip3', '$session_id', '$creby', '$cretime')";
		execRS($q);
		#$q = "INSERT INTO members (kdmember, kdgame, kdbank, norek, namarek, email, telp, isactive, tanggal_daftar, kode_random, ip1, ip2, ip3, session_id, creby, cretime) 
		#	VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
		#$param = array($kdmember, $igame, $ibank, $inorek, $inamarek, $iemail, $itelp, $isactive, $tanggal_daftar, $kode_random, $ip1, $ip2, $ip3, $session_id, $creby, $cretime);
		##print_r($param);
		#$rs=callRS($q, $param);
		$kode_random = str_replace("'", "", $kode_random);
		header("Location: /".memberFolder."/register/thanks/$kode_random");
	}
}
require(root."/_tpl/html_begin.php");
require(root."/".memberFolder."/_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 common-page">');
	cout('<div id="start-bodyxx" class="de-parallax-container">');
		cout('<div class="de-parallax" style="background-image:url(\'/img/slider-a.png\');"></div>');
	cout('</div>');
	cout('<script>');
		#cout('$(".parallax-window").parallax();');
		cout('$(window).scroll(function(){
			var scrollTop = $(window).scrollTop();
			if ($(".de-parallax-container").length) {
				var maxScrollTop = scrollTop>200?200:scrollTop;
				$(".de-parallax").css({ "transform":"translate3d(0, -"+ (scrollTop/10) +"%, 0)" });
			}
		});');
		cout('$(window).load(function(){
			if ($(".try-parallax .home-main-slide-img").length) {
				$(".try-parallax").css({ "height":$(".try-parallax .home-main-slide-img").height()+"px" });
			}
		});');
		cout('');
	cout('</script>');
	#cout('<div class="page-slideshow-container">');
	#	cout('<div class="page-slideshow dynamic-slide call-1"></div>');
	#cout('</div><!--/.page-slideshow-container-->');
	cout('<div class="container-custom-fluid game-lists">');
		cout('<div class="page-big-title">'.$lang[$_SESSION["lang"]]["page-title-daftar"].'</div>');
		if ($rand!="") {
			$rscm=array(); $qcm="SELECT * FROM members WHERE isactive=1 AND isdeleted=0 AND kode_random='$rand'";
			#$rscm = callRS($qcm);
			callRS($rscm, $qcm);
			if (count($rscm)!=0) {
				cout('<div class="special-box">');
					cout('<div class="panel panel-success text-center greet" style="margin:10px 0;">');
						cout('<div class="panel-heading">Pendaftaran Anda Berhasil!</div>');
					cout('</div><!-- /.panel -->');
					$rsw=array(); $qw = "SELECT * FROM s_website WHERE seksi = 'website_name'";
					callRS($rsw, $qw);
					cout('<div>Selamat bergabung bersama '.$rsw[0]["isi"].' dan nikmati pelayanan yang terlatih dari kami</div>');
					cout('<div>Silahkan tunggu 1-3 menit, Anda akan menerima SMS yang berisi Username dan Password Anda</div>');
					cout('<br/>');
					cout('<div class="acenter">');
						cout('Setelah menerima UserID Anda, silahkan coba login dahulu. Pastikan Anda telah berhasil login.');
						cout('<br/>Silahkan menghubungi Customer Service kami melalui chatting untuk mendapatkan Rekening Deposit kami.');
						cout('<br/><br/>Setelah Anda men-transfer deposit, silahkan isi form deposit (<a href="'.absDom.'/deposit" target="_blank">'.absDom.'/deposit</a>) dan tunggu 1-3 menit,');
						cout('<br/>maka kredit akan otomatis ditambahkan ke Username dan Anda sudah bisa mulai bermain.');
					cout('</div>');
				cout('</div>');
			} else {
				cout('<div class="special-box">');
					cout('<div class="panel panel-danger text-center greet" style="margin:10px 0;">');
						cout('<div class="panel-heading">Pendaftaran Anda Mengalami Kesalahan!</div>');
					cout('</div><!-- /.panel -->');
					cout('<div>Silahkan mencoba kembali pendaftaran Anda di: <a href="'.absDom.'/members/register">Daftar</a></div>');
					cout('<div>Apabila mengalami kendala atau kesulitan, Anda dapat menghubungi Customer Service Online kami.</div>');
					
					cout('<div>Silahkan menghubungi Customer Service kami untuk informasi lebih lanjut.</div>');
					cout('<div>Anda juga akan kami bantu sepenuhnya apabila Anda mengalami kesulitan lainnya.</div>');
				cout('</div>');
			}
			
		} else {
			cout('<div class="row">');
				cout('<div class="col-md-8 col-md-offset-2">');
					cout('<form method="post" action="" role="form">');
						cout('<input type="hidden" name="kirim" id="kirim" value="1" />');
						
						cout('<div class="row am-theme-row">');
							cout('<div class="col-xs-5 col-md-4"><label for="igame">'.$lang[$_SESSION["lang"]]["form-label-games"].'</label></div><!--/.col-xs-5 col-md-4-->');
							cout('<div class="col-xs-7 col-md-8">');
								$terr = isset($err["igame"]) && $err["igame"]!=""?' err ':'';
								cout('<div><select class="form-control field '.$terr.'" name="igame" id="igame" required autofocus>');
									cout('<option value="">- '.$lang[$_SESSION["lang"]]["form-placeholder-games"].' -</option>');
									$rsx=array(); $qx="SELECT * FROM games WHERE isactive=1";
									$rsx=array(); $qx="SELECT a.*, b.flag AS negara_flag, namanegara FROM games a 
										LEFT JOIN negara b ON b.kdnegara=a.kdnegara 
										WHERE a.isactive=1 AND b.kdlang='".$_SESSION["lang_id"]."' OR a.kdnegara='0'";
									#$rsx = callRS($qx);
									callRS($rsx, $qx);
									for ($x=0;$x<count($rsx);$x++) {
										$sel = intval($rsx[$x]["kdgame"])==intval($igame)?'selected="selected"':'';
										cout('<option value="'.$rsx[$x]["kdgame"].'" '.$sel.'>'.strtoupper($rsx[$x]["nama"]).'</option>');
									}
								cout('</select></div>');
								if (isset($err["igame"]) && $err["igame"]!="") { cout('<div class="alert alert-danger"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>'.$err["igame"].'</div>'); }
							cout('</div><!--/.col-xs-7 col-md-8-->');
						cout('</div><!-- /.row -->');
						cout('<div class="row am-theme-row">');
							cout('<div class="col-xs-5 col-md-4"><label for="ibank">'.$lang[$_SESSION["lang"]]["form-label-bank"].'</label></div><!-- /.col-sm-3 -->');
							cout('<div class="col-xs-7 col-md-8">');
								$terr = isset($err["ibank"]) && $err["ibank"]!=""?' err ':'';
								cout('<div><select class="form-control field '.$terr.'" name="ibank" id="ibank" required>');
									cout('<option value="">- '.$lang[$_SESSION["lang"]]["form-placeholder-bank"].' -</option>');
									$rsx=array(); $qx="SELECT a.*, b.flag AS negara_flag, namanegara FROM banks a 
										LEFT JOIN negara b ON b.kdnegara=a.kdnegara 
										WHERE a.isactive=1 AND b.kdlang='".$_SESSION["lang_id"]."' OR a.kdnegara='0'";
									#$rsx = callRS($qx);
									callRS($rsx, $qx);
									for ($x=0;$x<count($rsx);$x++) {
										$sel = intval($rsx[$x]["kdbank"])==intval($ibank)?'selected="selected"':'';
										cout('<option value="'.$rsx[$x]["kdbank"].'" '.$sel.'>'.$rsx[$x]["inisial"].' - '.$rsx[$x]["namabank"].'</option>');
									}
								cout('</select></div>');
								if (isset($err["ibank"]) && $err["ibank"]!="") { cout('<div class="alert alert-danger"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>'.$err["ibank"].'</div>'); }
							cout('</div><!-- /.col-sm-9 -->');
						cout('</div><!-- /.row -->');
						
						
						cout('<div class="row am-theme-row">');
							cout('<div class="col-xs-5 col-md-4"><label for="inorek">'.$lang[$_SESSION["lang"]]["form-label-norek"].'</label></div><!-- /.col-sm-3 -->');
							cout('<div class="col-xs-7 col-md-8">');
								$terr = isset($err["inorek"]) && $err["inorek"]!=""?' err ':'';
								cout('<div><input class="form-control field '.$terr.'" name="inorek" id="inorek" type="number" value="'.$inorek.'" placeholder="'.$lang[$_SESSION["lang"]]["form-placeholder-norek"].'" maxlength="15" required /></div>');
								if (isset($err["inorek"]) && $err["inorek"]!="") { cout('<div class="alert alert-danger"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>'.$err["inorek"].'</div>'); }
							cout('</div><!-- /.col-sm-9 -->');
						cout('</div><!-- /.row -->');
						
						cout('<div class="row am-theme-row">');
							cout('<div class="col-xs-5 col-md-4"><label for="inamarek">'.$lang[$_SESSION["lang"]]["form-label-namarek"].'</label></div><!-- /.col-sm-3 -->');
							cout('<div class="col-xs-7 col-md-8">');
								$terr = isset($err["inamarek"]) && $err["inamarek"]!=""?' err ':'';
								cout('<div><input class="form-control field '.$terr.'" name="inamarek" id="inamarek" type="text" value="'.$inamarek.'" placeholder="'.$lang[$_SESSION["lang"]]["form-placeholder-namarek"].'" required /></div>');
								if (isset($err["inamarek"]) && $err["inamarek"]!="") { cout('<div class="alert alert-danger"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>'.$err["inamarek"].'</div>'); }
							cout('</div><!-- /.col-xs-7 col-md-8 -->');
						cout('</div><!-- /.row -->');
						
						cout('<div class="row am-theme-row">');
							cout('<div class="col-xs-5 col-md-4"><label for="iemail">'.$lang[$_SESSION["lang"]]["form-label-email"].'</label></div><!-- /.col-sm-3 -->');
							cout('<div class="col-xs-7 col-md-8">');
								$terr = isset($err["iemail"]) && $err["iemail"]!=""?' err ':'';
								cout('<div><input class="form-control field '.$terr.'" name="iemail" id="iemail" type="email" value="'.$iemail.'" placeholder="'.$lang[$_SESSION["lang"]]["form-placeholder-email"].'" required /></div>');
								if (isset($err["iemail"]) && $err["iemail"]!="") { cout('<div class="alert alert-danger"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>'.$err["iemail"].'</div>'); }
							cout('</div><!-- /.col-sm-9 -->');
						cout('</div><!-- /.row -->');
						
						cout('<div class="row am-theme-row">');
							cout('<div class="col-xs-5 col-md-4"><label for="itelp">'.$lang[$_SESSION["lang"]]["form-label-telp"].'</label></div><!-- /.col-sm-3 -->');
							cout('<div class="col-xs-7 col-md-8">');
								$terr = isset($err["itelp"]) && $err["itelp"]!=""?' err ':'';
								cout('<div><input class="form-control field '.$terr.'" name="itelp" id="itelp" type="number" value="'.$itelp.'" placeholder="'.$lang[$_SESSION["lang"]]["form-placeholder-telp"].'" maxlength="14" required /></div>');
								if (isset($err["itelp"]) && $err["itelp"]!="") { cout('<div class="alert alert-danger"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>'.$err["itelp"].'</div>'); }
							cout('</div><!-- /.col-sm-9 -->');
						cout('</div><!-- /.row -->');
						
						cout('<div class="row am-theme-row">');
							cout('<div class="col-xs-5 col-md-4"><label for="ipass">'.$lang[$_SESSION["lang"]]["form-label-pass-dash"].'</label></div><!-- /.col-sm-3 -->');
							cout('<div class="col-xs-7 col-md-8">');
								$terr = isset($err["ipass"]) && $err["ipass"]!=""?' err ':'';
								cout('<div><input class="form-control field '.$terr.'" name="ipass" id="ipass" type="password" placeholder="'.$lang[$_SESSION["lang"]]["form-placeholder-pass-dash"].'" required /></div>');
								if (isset($err["ipass"]) && $err["ipass"]!="") { cout('<div class="alert alert-danger"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>'.$err["itelp"].'</div>'); }
							cout('</div><!-- /.col-sm-9 -->');
						cout('</div><!-- /.row -->');
						
						cout('<div class="row am-theme-row">');
							cout('<div class="col-xs-5 col-md-4"><label for="ival">'.$lang[$_SESSION["lang"]]["form-label-valid"].'</label></div><!-- /.col-sm-3 -->');
							cout('<div class="col-xs-7 col-md-8">');
								cout('<div class="row">');
									cout('<div class="col-xs-7 col-md-3">');
										cout('<img class="captcha-main-image center-block pointer" src="/gfx/captcha/'.rand(1000000000,9999999999).'.gif/captcha_order" alt="Security Code" />');
									cout('</div><!-- /.col-xs-7 col-md-3-->');
									cout('<div class="col-xs-5 col-md-9">');
										$terr = isset($err["ival"]) && $err["ival"]!=""?' err ':'';
										cout('<div><input class="form-control field '.$terr.'" name="ival" id="ival" value="'.$ival.'" size="6" maxlength="6" placeholder="'.$lang[$_SESSION["lang"]]["form-placeholder-valid"].'" required /></div>');
										if (isset($err["ival"]) && $err["ival"]!="") { cout('<div class="alert alert-danger"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>'.$err["ival"].'</div>'); }
									cout('</div><!-- /.col-xs-5 col-md-9-->');
								cout('</div><!-- /.row -->');
							cout('</div><!-- /.col-sm-9 -->');
						cout('</div><!-- /.row -->');
						cout('<div class="row">');
							cout('<div class="col-sm-12 text-center">');
								cout('<input class="button" type="submit" value="Daftar" />');
							cout('</div><!-- /.col-sm-12 -->');
						cout('</div><!-- /.row -->');
						cout('<br/><br/>');
					cout('</form>');
				cout('</div><!--/.col-md-10 col-md-offset-2-->');
				cout('<script>
					$(document).ready(function(){
						
					});
				</script>');
				cout('<div class="row for-footer">');
					$rsr=array(); $qr="SELECT * FROM cara_main WHERE LOWER(judul) LIKE '%daftar%'";
					callRS($rsr, $qr);
					$isi = str_replace("\n", "<br/>", $rsr[0]["isi"]);
					$isi = str_replace("[h5]", '<h5 class="small text-warning">', $isi);
					$isi = str_replace("[/h5]", '</h5>', $isi);
					$isi = str_replace("[p]", '<p>', $isi);
					$isi = str_replace("[/p]", '</p>', $isi);
					$isi = str_replace('style="font-size:x-small;"', '', $isi);
					$isi = str_replace('style="font-size: x-small;"', '', $isi);
					cout('<div class="col-md-10 col-md-offset-2">');
					cout('<div class="special-box">');
						cout($isi);
					cout('</div><!--/.row for-footer-->');
				cout('</div><!--/.col-md-10 col-md-offset-2-->');
			cout('</div><!--/.row for-footer-->');
		}
	cout('</div><!--/.container-custom-fluid game-lists-->');
cout('</div><!--/.container-fluid common-page-->');

require(root."/".memberFolder."/_tpl/body_close.php");
?>