Login page done

This commit is contained in:
Li Chen 2013-10-09 23:41:52 +02:00
commit b687a54fb0
6 changed files with 111 additions and 1 deletions

View 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");
}

6
onyx/lang/fr/login.json Normal file
View file

@ -0,0 +1,6 @@
{
"title":"Veuillez vous connecter",
"login":"Login",
"password":"Mot de passe",
"connect":"Se connecter"
}

View file

@ -0,0 +1,18 @@
{extends file="layout-nav.tpl"}
{block name=head}
<link href="css/login.css" rel="stylesheet">
{/block}
{block name=content}
<div class="container">
<form class="form-signin" method="post" action="login">
<h3 class="form-signin-heading">{text file="login" path=title}</h3>
<input name="username" type="text" class="form-control" placeholder="{text file="login" path=login}" autofocus>
<input name="password" type="password" class="form-control" placeholder="{text file="login" path=password}">
<button class="btn btn-lg btn-primary btn-block" type="submit">{text file="login" path=connect}</button>
</form>
</div> <!-- /container -->
{/block}

View file

@ -0,0 +1,11 @@
{extends file="layout-nav.tpl"}
{block name=head}
<link href="css/home.css" rel="stylesheet">
{/block}
{block name=content}
<h1>
YOUPIII !!!
</h1>
{/block}