Merge branch 'master' of ssh://git.nemunai.re:6224/fic2014-server
This commit is contained in:
commit
edd8eb45a5
13 changed files with 194 additions and 17 deletions
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
function mdp($username, $mdp)
|
||||
{
|
||||
return hash('whirlpool', strtoupper($username).':'.$mdp);
|
||||
return hash('whirlpool', strtoupper($username).'#'.$mdp);
|
||||
}
|
||||
|
||||
function ip()
|
||||
|
|
@ -93,4 +93,4 @@ function eregmenu($pattern, $string)
|
|||
return preg_match("#".$pattern."#ui", $string);
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
|||
34
onyx/include/public/login.php
Normal file
34
onyx/include/public/login.php
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
if (!defined('ONYX')) exit;
|
||||
|
||||
if ($SESS->level < 1)
|
||||
{
|
||||
if (isset($_POST['username']) && isset($_POST['password']))
|
||||
{
|
||||
$username = $_POST['username'];
|
||||
$password = $_POST['password'];
|
||||
|
||||
$bdd = new BDD();
|
||||
|
||||
// TODO: use function
|
||||
$hash = mdp($bdd->escape($username), $bdd->escape($password));
|
||||
$result = $bdd->unique_query("SELECT username, auth_level FROM users
|
||||
WHERE username='$username'
|
||||
AND password=unhex('$hash')");
|
||||
|
||||
if (!empty($result) && $result['auth_level'] != 0)
|
||||
{
|
||||
$SESS->level = $result['auth_level'];
|
||||
$SESS->values = $result;
|
||||
$SESS->put($username);
|
||||
header("Location: /home");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$page = "public/login";
|
||||
}
|
||||
else
|
||||
{
|
||||
// Show some page ?
|
||||
header("Location: /home");
|
||||
}
|
||||
Reference in a new issue