<?php
if(empty($user['id'])){
$login = "";
if(isset($_POST['cfms'])) {
$login = system :: check($_POST['login']);
$password = system :: check($_POST['password']);
$email_l = system :: utf_strlen($login);
$password_l = system :: utf_strlen($password);
$loginUser = DB :: $pdo -> queryFetch("SELECT `sid`, `id`, `password_update` FROM `users` WHERE (`login` = ? OR `email` = ?) AND (`password` = ? OR `password` = ?) LIMIT 1;", [$login, $login, $password, System::bhash($password)]);
if(!empty($loginUser['sid'])) {
if($email_l > 0 && $password_l > 0) {
$access = rand(11513,95658).rand(434,898);
DB :: $pdo -> query("UPDATE `users` SET `access` = ? WHERE `login` = ? AND `password` = ?;", [$access, $login, $password]);
if ($loginUser['password_update'] == 0)
{
DB::$pdo->query("UPDATE `users` SET `password` = ?, `password_update` = ? WHERE `id` = ?;", [System::bhash($password), 1, $loginUser['id']]);
}
setcookie('xsid', $loginUser['sid'], time()+60*60*24*365);
system :: redirect(NULL, "/");
} else {
$e = "Пустое поле.";
}
} else {
$e = "Не верный E-mail или пароль.";
}
}
require (CORE."head.php");
if(isset($e)){ system :: show($e); }
?>
<div class="app-block">
<div style="height: 62px; background: url(https://img3.goodfon.ru/original/1366x768/b/cf/social-media-icons-3d-cubes.jpg) 10% 10% no-repeat; background-size: cover; "></div>
<div class="list">
<div class="app-block-w">
<div class="_lh-n" style="margin-top: 20px;">
<div class="vsetime">
<span class="vsetitext"><span class="_gray">К нам уже присоеденились</span></span>
</div></div>
<?
if ($data = DB :: $pdo -> query("SELECT * FROM `users` ORDER BY RAND() DESC LIMIT 3")->fetchAll())
{
echo"<div class='_center'>";
foreach($data as $i)
{
echo'<a href="'.profile :: getLink($i).'"><div style="display: inline-block; margin-right: 9px;">
'.profile :: userAvatar($i,0).'
</div></a>';
}
echo "</div>";
}?>
<form method="post" action="" data-noajax="">
<div style="margin-bottom: 3px;">
<label class="_gray _dbl telotext" for="index-login">E-mail или имя пользователя:</label>
<input type="text" class="telo _w-100" name="login" value="<?=system :: check($login)?>" placeholder="еmail или логин" id="index-login">
</div>
<div>
<label class="_gray _dbl telotext" for="index-password">Пароль:</label>
<input type="password" class="telo _w-100" name="password" placeholder="Пароль" id="index-password">
</div>
<div class="_center">
<div style="margin-top: 10px;">
<input type="submit" class="main-telo _w-20 " load="1" name="cfms" value="Войти"></div>
</div>
<div class="_lh-n" style="margin-top: 20px;">
<div class="vsetime">
<span class="vsetitext"><span class="_gray">Еще не зарегистрированы?</span></span>
</div>
<div class="_center">
<a href="/signup" class="main-telo_b _dbl _w-50">Создать новый аккаунт</a>
</div>
</div>
<div class="_center restore">
<a href="/restore" class="touch-cont _oh bit"><b> Восстановить доступ</b></a>
</div>
</form>
</div>
</div>
<?php
} else {
if(isset($_GET['logout'])) {
if(@$_GET['access'] == $user['access']) {
setcookie('xsid', '', time());
system :: redirect(NULL, "/");
} else {
$e = "Не верный ключ доступа.";
}
}
require (CORE."head.php"); #Шапка
if(isset($e)){ system :: show($e); } #Вывод ошибок
system :: redirect(NULL, "".profile :: getLink($user).""); #Перенаправления на profile
}
require (CORE."foot.php"); #Низ