View file moduls/enter.php

File size: 1.97Kb
<?php
include_once'../system/xcms_core.php';$title='Авторизация';
if(!$user){
	if(!empty($_POST['login']) or !empty($_GET['login'])){
		if(!empty($_POST['login']))$login=protect($_POST['login']);
		if(!empty($_POST['pass']))$pass=protect(pass($_POST['pass']));
		if(!empty($_GET['login']))$login=protect($_GET['login']);
		if(!empty($_GET['password']))$pass=protect(pass($_GET['password']));
		$count=$db->query("select * from `user` where `login`='$login' and `password`='$pass'")->fetch(PDO::FETCH_ASSOC);
		if($count){
			setcookie('login', $login, time()+3600*24*365, '/');
			setcookie('password', $pass, time()+3600*24*365, '/');
			if($_COOKIE['style']=='web')require_once '../system/web_head.php'; else require_once '../system/head.php';
			$db->prepare("update `user` set `auth`='$time' where `login`='$login'")->execute();
			if($count['auth'])echo '<div class="menu">Ваш последний визит: '.clock($count['auth']).'</div>';
			echo'<div class="menu">Авторизовались &rarr; <a href="/">Далее</a></div>';
		}else{
			if($_COOKIE['style']=='web')require_once '../system/web_head.php'; else require_once '../system/head.php';
			echo'<div class="menu">Неверно введен логин и(или) пароль</div>';
		}
	}else{
		if($_COOKIE['style']=='web')require_once '../system/web_head.php'; else require_once '../system/head.php';
		echo'<form action="#" method="post">
		<div class="menu">
		<div style="text-align:center;">Авторизация | <a href="/registration">Регистрация</a></div>
		Логин:<br /><input type="text" name="login"><br />
		Пароль:<br /><input type="password" name="pass"><br />
		<input type="submit" value="Войти">
		</div>
		<div class="touch">
			<div class="menu"><a href="/pass">Забыл пароль</a></div>
		</div>
		</form>';
	}
}
back('/');
if($_COOKIE['style']=='web')require_once '../system/web_foot.php'; else require_once '../system/foot.php';
?>