Файл: modules/user/sign_in.php
Строк: 67
<?php
/**
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) 2013, Taras Chornyi, Sergiy Mazurenko, Ivan Kotliar
* @link http://perf-engine.net
* @package PerfEngine
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
if(User::logged()) redirect('/');
if(!empty($_GET['nick']) && !empty($_GET['password']))
{
$nick = escape($_GET['nick']);
$pass = crypto(input($_GET['password']));
if($db->query("SELECT * FROM `users` WHERE (`nick` = '". $nick ."' OR `email` = '". $nick ."') AND `password` = '". $pass ."'")->rowCount() == 1)
{
$userl = $db->query("SELECT * FROM `users` WHERE (`nick` = '". $nick ."' OR `email` = '". $nick ."') AND `password` = '". $pass ."'")->fetch();
setcookie('uid', $userl['id'], time()+60*60*24*1024, '/');
setcookie('password', $pass, time()+60*60*24*1024, '/');
$_SESSION['uid'] = $userl['id'];
$_SESSION['password'] = $pass;
header('Location: /');
exit;
}
else
{
$_SESSION['alert'] = array('type' => 'error', 'value' => _t('fail_a'));
}
}
elseif(!empty($_POST['nick']) && !empty($_POST['password']))
{
$nick = escape($_POST['nick']);
$pass = crypto(input($_POST['password']));
if($db->query("SELECT * FROM `users` WHERE (`nick` = '". $nick ."' OR `email` = '". $nick ."') AND `password` = '". $pass ."'")->rowCount() == 1)
{
$userl = $db->query("SELECT * FROM `users` WHERE (`nick` = '". $nick ."' OR `email` = '". $nick ."') AND `password` = '". $pass ."'")->fetch();
setcookie('uid', $userl['id'], time()+60*60*24*1024, '/');
setcookie('password', $pass, time()+60*60*24*1024, '/');
$_SESSION['uid'] = $userl['id'];
$_SESSION['password'] = $pass;
header('Location: /');
exit;
}
else
{
$_SESSION['alert'] = array('type' => 'error', 'value' => _t('fail_a'));
}
}
$page = 'auth';
$title = _t('sign_in');
include_header($title);
$tpl->div('title', _t('sign_in'));
// if(isset($err)) { $tpl->div('error', $err); }
echo '<div class="menu">
<form action="?" method="post">
'. _t('nick') .' / E-Mail:<br/>
<input type="text" name="nick" /><br/>
'. _t('password') .':<br/>
<input type="password" name="password" /><br/>
<input type="submit" value="'. _t('sign_in') .'" />
</form>
</div>';
$tpl->div('block', img('back.png').' <a href="/user/recovery?">'._t('recovery').'</a><br/>'.
HICO .'<a href="/">'. _t('home') .'</a>');
include_footer();
?>