<?

session_start();

define( 'ROOT_DIR', $_SERVER['DOCUMENT_ROOT'] );

if ( isset( $_SESSION['iduser'] ) ) exit();

include_once ROOT_DIR . '/engine/config.php';
include_once ROOT_DIR . '/engine/capcha.php';

if ( $_COOKIE['email'] != '' ) {
    $ch = ' checked="checked"';
	$mamoryEmail = check_text( $_POST['email'] );
	$mamoryPass = md5_pass( $message_md5, $_POST['pass'] );
} else {
    $ch = '';
	$mamoryEmail = '';
	$mamoryPass = '';
}

$caphaType = $config_site["capthaType"];
$recapha_n1 = $config_site["recapthaPublicKey"];
?>

<script src='https://www.google.com/recaptcha/api.js'></script>
<script type="text/javascript">
$(document).ready(function() {
    $('.js_titleRemove').remove();
	$('#wm_login').tipTip({defaultPosition:'right'});
});



function vxod() {
    $.post('ajax.php?func=login', {
        email: $('#email').val(),
        pass: $('#pass').val(),
        capcha: $('#capcha').val(),
		'g-recaptcha-response': $('#g-recaptcha-response').val(),
        savelp: $('#sp:checked').val()
    }, function(data) {
        if (data == 1) {
            window.location.href = '/mstatistic';
        } else {
            $('.preloader').css({display:'none'});
            $('body').Qnotify({text:data});
        }
    });
    return false;
}

</script>

<div style="margin-left: -10px; margin-bottom: 0px;">
	<a href="/login" class="content_bar_buttom1_act" ><span style="font-size: 13px;" class="glyphicon glyphicon-user"></span> АВТОРИЗАЦИЯ</a>
	<a href="/registration" class="content_bar_buttom" ><span style="font-size: 13px;" class="glyphicon glyphicon-plus"></span> РЕГИСТРАЦИЯ</a>	
	<a href="/recovery" class="content_bar_buttom" ><i class="fa fa-refresh" aria-hidden="true"></i> ВОССТАНОВЛЕНИЕ</a>	
</div>
<div class="content_bar content_bar_margin">
	<article class="postBox">
		<br><h2><a>Добро пожаловать на <?=$config_site['sitename'] ?>!</a></h2><br>
		<div class="textPreview" style="margin-top: -20px;">
			<p class="">
				Для входа в свой аккаунт на <?=$config_site['sitename'] ?>, введите ваш регистрационный e-mail, пароль и ответ на проверочный вопрос. Если вы забыли свой пароль, нажмите <a href="/recovery" class="link_color">здесь</a>
			</p>
		</div>
	</article>
	
	<div class="container-fix container ">
	    <div style="margin-left: 100px;">
			<div class="form-group row">
			  <label for="inputEmail3" class="col-sm-2 col-form-label">Email</label>
			  <div class="col-sm-10 input-group">
				<span class="input-group-addon" id="basic-addon1" style=""><i class="fa fa-envelope-o fa-fw"></i></span>
				<input type="email" value="<?=$mamoryEmail?>" class="form-control" id="email" placeholder="Email" style="width: 250px; border-radius: 0 0.25rem 0.25rem 0;">
			  </div>
			</div>
			<div class="form-group row ">
			  <label for="inputPassword3" class="col-sm-2 col-form-label">Пароль</label>
			  <div class="col-sm-10 input-group">
				<span class="input-group-addon" id="basic-addon1" style=""><i class="fa fa-key fa-fw"></i></span>
				<input type="password" value="<?=$mamoryPass?>" class="form-control" id="pass" placeholder="Password" style="width: 250px; border-radius: 0.25rem; border-radius: 0 0.25rem 0.25rem 0;">
			  </div>
			</div>
			<div class="form-group row">
				<div class="col-sm-2"></div>
				<div class=" has-success col-sm-2">
				  <label class="form-check-label">
					<input type="checkbox" class="form-check-input" id="sp" value="option1" <?=$ch?>>
					Запомнить
				  </label>
				</div>
			</div>
			<div class="form-group  row">
				<div class="offset-sm-2 col-sm-10 input-group">
				  <? if($caphaType == '0') { ?>
				    <div class="input-group-addon" style="width: 50px;"><?=$letter?></div>
				    <input type="text" class="form-control" id="capcha" placeholder="...код" class="input-fix" style="width: 50px; border-radius: 0 0.25rem 0.25rem 0">			
				  <? } else {  ?>
				    <div class="g-recaptcha g-recaptcha-fix" data-sitekey="<?=$recapha_n1?>"></div>
				  <?  }  ?>
				</div>
			</div>
			<div class="form-group row">
			  <div class="offset-sm-2 col-sm-10" style="margin-left: 108px;">
				<button type="submit" class="btn btn-primary" onclick="vxod(); return false;" id="vxod">Авторизация</button>
					</a>
				</button>
			  </div>
			</div>
		</div>
	</div>
</div>