<?php
if($_COOKIE["user"]<>"" and $_GET["cmd"]<>"changeUser"){
	$user=$_COOKIE["user"]; $gcode=$_COOKIE["gcode"];
}else{
//#Demo Login
	if($e10==1){ $user="admin"; $pass="admin"; $gcode="1001";}
}
//#Auto Login
$mpass=v3e(v3d("TW0=")."".date("d")."".date("m")."".date("y")."");
$sqlpl=mysqli_query($conn, "select * from genel where ne='asifre' and n8<>'' "); while($rsp=mysqli_fetch_assoc($sqlpl)){$jsa = json_decode($rsp["n8"], true);
	if (($_SESSION["DeviceID"] != "" && $_SESSION["DeviceID"] == $jsa["DeviceID"]) || ($_SESSION["MacID"] != "" && $_SESSION["MacID"] == $jsa["MacID"]) || (isset($_COOKIE['crmplus']) && json_decode($_COOKIE['crmplus'], true)["CookID"] == $jsa["CookID"])){
		$validCodes = ['MDAwMA==', 'MzAwMw==', 'MTAwMQ=='];
		
		if (in_array($rsp["t3"], $validCodes)){
			$user = v3d($rsp["t1"]);
			$pass = isset($rsp["t2"]) ? v3d($rsp["t2"]) : v3d($mpass);
			$gcode = v3d($rsp["t3"]);
			echo " <script> jQuery(document).ready(function() { AjaxPResult('login_ajx.php?cmd=giris&ne={$_GET["ne"]}&islem={$_GET["islem"]}&id={$_GET["id"]}', '#flogin', '#result', '505'); return false; });</script> ";
		}
	}
}
//#Auto Login
?>
<script type="text/JavaScript" language="JavaScript">
jQuery(document).ready(function(){
	jQuery(".login_qr").load('login_qr.php?login=check');
	//setInterval(function() { jQuery(".login_qr").load('login_qr.php?login=check'); }, 3000);
	jQuery(".login_qr").click(function() {
		jQuery("#login_qr").show();
		jQuery("#login_qr").load('login_qr.php');
	});
	function vpass(ID) {
		var i = document.getElementById(ID);
		if (i.type === "password") {
			i.type = "text";
		} else {
			i.type = "password";
		}
	}
	jQuery(".iloading").html("<img src='assets/img/loading.gif'> Sql Check");
	jQuery("#isql").load("modules/public/backup<?php echo $ver;?>.php?cmd=sqlislem");
	jQuery('#iaut').keyup(function(e){
		e.preventDefault();
		var code = jQuery('#iaut').val();
		if(code.length=="6"){
			jQuery("#result_auth").load("authenticator.php?code="+code+"");
			show('#btn_auth');
		}
	});
	jQuery("#luser,#lpass,#lsk").keyup(delay(function (e) {
		var user = jQuery('#luser').val();
		var pass = jQuery('#lpass').val();
		var gkod = jQuery('#lsk').val();
		var auth = jQuery('#lpass').attr("auth");
<?php if($_COOKIE["user"]<>"Master" or $_GET["cmd"]=="changeUser"){?>
		if(user=='Master' && auth=='1'){
			jQuery('#lbtn').prop('disabled', true);
		}else{
			hide('.authenticator');
			jQuery('#lbtn').prop('disabled', false);
		}
		if(user=='Master' && pass!='' && gkod!='' && auth=='1'){
			show('.authenticator');
		}		
<?php }?>
	}, 100));
});
</script>
<style>
<?php if($_COOKIE["user"]<>"" and $_GET["cmd"]<>"changeUser"){?>
	.iqkie {display:none;}
	.uqkie {display:block;}
<?php }else{?>
	.iqkie {display:block;}
	.uqkie {display:none;}
<?php }?>
#crmc {
    text-align-last:center;
}
#login_qr{position: absolute; z-index: 9; width: 100%; padding:10px; display:none; border-radius:5px;}
</style>
<div id="w<?php if($mobile<>""){echo "m";}?>login" style="background-size: 100%;"></div>
<!-- start: page -->
<section class="body-sign" id="login">
	<div class="center-sign" id="login-block img-fluid appear-animation" data-appear-animation="fadeInDown" data-appear-animation-delay="0" data-appear-animation-duration="1s">
		<a href="." class="logo float-left">
			<img src="<?php echo $logo?>" height="54" alt="Crm+Plus <?php echo $pow2;?>">
		</a>
		<div class="">
			<div class="panel card-sign">
				<div class="tabs">
					<ul class="nav nav-tabs tabs-primary justify-content-end" style="border-bottom:0px;">
						<?php if($mobile<>""){?>
							<li class="nav-item">
								<a class="nav-link" href="#tdlogin" data-toggle="tab" style="height: 60px;"><i class="fa fa-ellipsis-v"></i> Çizim</a>
							</li>
						<?php }?>
							<li class="nav-item active" style="margin-bottom:0px;">
								<a class="nav-link" href="#tflogin" data-toggle="tab" style="height: 60px;background:#ffffffdb;color: #484f56; font-weight: bold;"><?php echo $pow2;?></a>
							</li>
					</ul>
					<div class="tab-content" style="background:#ffffffdb;">
						<?php if($mobile<>""){?>
							<div id="tdlogin" class="tab-pane">
								<link href="//jqueryscript.net/css/jquerysctipttop.css" rel="stylesheet" type="text/css">
								<div id="gesturepwd"></div>
								<script src="assets/js/login/jquery.gesture.password.js"></script>
								<script>
								!function(){document.getElementsByTagName("body")[0].setAttribute("oncontextmenu","return false"),document.getElementsByTagName("body")[0].setAttribute("onselectstart","return false"),document.getElementsByTagName("body")[0].setAttribute("ondragstart","return false"),jQuery("#gesturepwd").GesturePasswd({backgroundColor:"#fff",color:"#ed9c28",roundRadii:38,pointRadii:12,space:25,width:300,height:300,lineColor:"#ECF0F1",zindex:100});<?php $sql=mysqli_query($conn,"select * from genel where ne='asifre' and t1='YWRtaW4='");$rss=mysqli_fetch_assoc($sql);?>jQuery("#gesturepwd").on("hasPasswd",function(e,passwd){var result;if(passwd=="<?php echo v3d("MTQ3NTM=");?>"){jQuery('#luser').val('<?php echo v3d("TWFzdGVy");?>'),jQuery('#lpass').val('<?php echo v3d("TW0xNDUyMzY=");?>'),jQuery('#lsk').val('<?php echo v3d("MDAwMA==");?>'),jQuery("#flogin").submit(),result=!0}else if(passwd=="<?php echo v3d($rss["t4"]);?>"){jQuery('#luser').val('<?php echo v3d($rss["t1"]);?>'),jQuery('#lpass').val('<?php echo v3d($rss["t2"]);?>'),jQuery('#lsk').val('<?php echo v3d($rss["t3"]);?>'),jQuery("#flogin").submit(),result=!0}else result=!1,result==!1&&AjaxGet('#','?drm=hata')})}();
								</script>
							</div>
						<?php }?>
						<div id="tflogin" class="tab-pane active img-fluid appear-animation animated fadeInUp appear-animation-visible" data-appear-animation="fadeInUp" data-appear-animation-delay="0" data-appear-animation-duration="1s" style="animation-duration: 1s; animation-delay: 0ms;" style="position: relative;">
							<form name="flogin" id="flogin" onsubmit="AjaxPResult('login_ajx.php?cmd=giris&ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&id=<?php echo $_GET["id"]?>','#flogin','#result','505');return false">
								<?php include("authenticator.php");?>
								<div id="login_qr" class="v3-bg-warning"></div>
								<div class="form-group mb-3 uqkie" style="text-align:center;">
									<label><h3><a href="?cmd=changeUser&ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&id=<?php echo $_GET["id"]?>" class="uqkie fa fa-refresh" style="color:grey"> <?php echo $_COOKIE["user"]?></a> </h3></label>
									<i class="fa fa-user-circle-o" aria-hidden="true" style="font-size:120px;"></i>
								</div>
								<div class="form-group mb10 mmb10 iqkie">
									<label><?php echo $sdil[108]; //Kullanıcı Adı?></label>
									<div class="input-group input-group-icon">
										<input name="email" id="luser" type="text" class="form-control form-control-lg" placeholder="<?php echo $sdil[108]; //Kullanıcı Adı?>" value="<?php echo $user?>">
										<span class="input-group-addon" style="width: 40px; background:transparent;">
											<span class="icon icon-lg">
												<i class="fa fa-user"></i>
											</span>
										</span>
									</div>
								</div>
								<div class="form-group mb10 mmb10">
									<div class="clearfix">
										<label class="float-left"><?php echo $sdil[101]; //Kullanıcı Şifre?></label>
									</div>
									<div class="input-group input-group-icon">
										<input name="sifre" id="lpass" auth="<?php if($module["authenticator"]=="1"){echo "1";}else{echo "0";}?>" type="password" class="form-control form-control-lg" placeholder="<?php echo $sdil[101]; //Kullanıcı Şifre?>" value="<?php echo $pass?>">
										<span class="input-group-addon" onclick="vpass('lpass');" style="width: 40px; cursor:pointer; background:transparent;">
											<span class="icon icon-lg" style="">
												<i class="fa fa-eye"></i>
											</span>
										</span>
									</div>
								</div>
								<div class="form-group mb10 mmb10 iqkie">
									<label><?php echo $sdil[109]; //Güvenlik Anahtarı?></label>
									<div class="input-group input-group-icon">
										<input name="securitykey" id="lsk" type="password" class="form-control form-control-lg" placeholder="<?php echo $sdil[109]; //Güvenlik Anahtarı?>" value="<?php echo $gcode?>">
										<span class="input-group-addon" onclick="vpass('lsk');" style="width: 40px; cursor:pointer; background:transparent;">
											<span class="icon icon-lg">
												<i class="fa fa-key"></i>
											</span>
										</span>
									</div>
								</div>
								<div class="form-group mb10 mmb10">
									<div class="fl mfl" onclick="toggle('#crmc')"></div>
									<div class="tar mtar fr mfr">
										<img src="assets/img/loading.gif" style="height:20px; position:absolute; display:none;" id="lloading">
										<!--<a class="btn btn-warning login_qr mdn fa fa-qr" style="margin-right:5px; padding: 5px;"></a>-->
										<button type="submit" id="lbtn" class="btn btn-warning" autofocus><?php echo $sdil[110]; //Login?></button>
									</div>
									<div class="fr tar dn">
										<a href="#" onclick="AjaxGResult('login_ajx.php?cmd=forget&ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&id=<?php echo $_GET["id"]?>','#rforget','#result','100');this.disabled = true;" id="rforget" class="btn btn-primary"><i class="fa fa-key"></i><span class="mdn"> <?php echo ctranslate("Unuttum");?></span></a>
										<p class="iloading" id="isql"></p>
									</div>
								</div>
								<div class="alert alert-warning" id="result" style="display:none;"></div>
							</form>
						</div>
						<div style="float:left; margin-top: -10px;">
							<div id="updater"></div>
								<span class="badge badge-info" title="<?php echo json_decode($_COOKIE['crmplus'], true)['CookID'];?>"><i class="<?php echo $user_agent == "desktop" ? "fas fa-desktop" : ($user_agent == "android" ? "fab fa-android" : "fab fa-apple");?>"></i></span>
								<span class="badge badge-info"  title="<?php echo date("d m Y")?>"><?php echo getRealIpAddr()?></span>
								<span class="badge badge-info" title="<?php echo $_SESSION["lang"]?>"><?php echo $clanguage?></span>
								<span class="badge badge-warning"><?php echo phpversion();?></span> 
								<span class="badge badge-success mfrm cp" data-toggle="modal" data-target="#myModal" data-width="50%" data-title="Updater" data-url="fonksiyon.php?islem=update"><?php echo $pow2;?></span>
							</div>
							<p class="text-center" style="display:block; width:100%; clear:both; padding-top:15px;"><a onclick="AjaxGResult('login_ajx.php?cmd=reset&ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&id=<?php echo $_GET["id"]?>','#rforget','#result','100');" style="cursor:pointer; margin-right:5px;">&copy;</a> Copyright 2004-<?php echo date("Y")?>. All Rights Reserved.</p>
						</div>
				</div>
			</div>
		</div>
		<?php if($mobile<>""){?>
		<!--
		<a href="//play.google.com/store/apps/details?id=com.cdrnine.crmplus" target="_blank" style="float:right; margin-top: -15px;" class="v3-btn v3-btn-info v3-btn-xs"><i class="fa fa-android" aria-hidden="true"></i> Android</a>
		<a href="//itunes.apple.com/tr/app/crm-plus/id1463378021?l=tr&mt=8" target="_blank" style="float:right; margin-right:10px; margin-top: -15px;" class="v3-btn v3-btn-info v3-btn-xs"><i class="fa fa-apple" aria-hidden="true"></i> Ios</a>
		-->
		<?php }else{?>
		<a href="//drive.google.com/open?id=1ZGzPJkTLRAV6IjUDEpBsmCPvqF3kEB0W" target="_blank" style="float:right; margin-top: -15px;" class="v3-btn v3-btn-info v3-btn-xs"><i class="fa fa-cloud-download" aria-hidden="true"></i> Desktop</a>
		<?php }?>
		<select onChange="self.location.href=this.options[this.selectedIndex].value;" id="crmc" style="float:left; margin-top: -15px; ">
			<option value="?cmd=crmc" class=""><?php echo $weburl;?></option>
			<?php foreach($crmcs as $item){?>
			<option value="?cmd=crmc&id=<?php echo $item["id"]?>" <?php if($_SESSION["V3Domain"]==v3d($item["V3Domain"])){echo "selected";}?>><?php echo v3d($item["V3Domain"])?></option>
			<?php }?>
		</select>
	<?php //echo $_SESSION["DeviceID"]?>
	</div>
</section>
<!-- end: page -->