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");
|
||||
}
|
||||
6
onyx/lang/fr/login.json
Normal file
6
onyx/lang/fr/login.json
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"title":"Veuillez vous connecter",
|
||||
"login":"Login",
|
||||
"password":"Mot de passe",
|
||||
"connect":"Se connecter"
|
||||
}
|
||||
|
|
@ -85,6 +85,10 @@ function decode_ip($int_ip)
|
|||
|
||||
function encode_ip($ip=FALSE)
|
||||
{
|
||||
if(!$ip && !empty($_SERVER["HTTP_X_FORWARDED_FOR"]))
|
||||
$ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
|
||||
if(!$ip && !empty($_SERVER["HTTP_X_REAL_IP"]))
|
||||
$ip = $_SERVER["HTTP_X_REAL_IP"];
|
||||
if(!$ip)
|
||||
$ip = $_SERVER['REMOTE_ADDR'];
|
||||
|
||||
|
|
|
|||
34
onyx/tpl/bootstrap/layout-nav.tpl
Normal file
34
onyx/tpl/bootstrap/layout-nav.tpl
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
{extends file="layout.tpl"}
|
||||
{block name=body}
|
||||
<!-- TODO: message dans lang-->
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="/home">FIC</a>
|
||||
</div>
|
||||
<div class="collapse navbar-collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li><a href="/home">Home</a></li>
|
||||
<li><a href="#about">About</a></li>
|
||||
<li><a href="#contact">Contact</a></li>
|
||||
</ul>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li><a href="/login">Login</a></li>
|
||||
</ul>
|
||||
</div><!--/.nav-collapse -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{if $ERRmessage}
|
||||
<div class="alert alert-{$ERRcolor}">
|
||||
<button class="close" data-dismiss="alert">×</button>
|
||||
<i class="icon-warning-sign"></i> {$ERRmessage}
|
||||
</div>
|
||||
{/if}
|
||||
{block name=content}{/block}
|
||||
{/block}
|
||||
18
onyx/tpl/bootstrap/public/login.tpl
Normal file
18
onyx/tpl/bootstrap/public/login.tpl
Normal 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}
|
||||
11
onyx/tpl/bootstrap/users/home.tpl
Normal file
11
onyx/tpl/bootstrap/users/home.tpl
Normal 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}
|
||||
Reference in a new issue