Merge branch 'master' of ssh://git.nemunai.re:6224/fic2014-server
This commit is contained in:
commit
edd8eb45a5
@ -3,7 +3,7 @@
|
||||
-- http://www.phpmyadmin.net
|
||||
--
|
||||
-- Client: localhost
|
||||
-- Généré le: Mer 09 Octobre 2013 à 18:26
|
||||
-- Généré le: Mer 09 Octobre 2013 à 23:12
|
||||
-- Version du serveur: 5.5.32-log
|
||||
-- Version de PHP: 5.5.0-pl0-gentoo
|
||||
|
||||
@ -21,24 +21,40 @@ SET time_zone = "+00:00";
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `exercices` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`id` varchar(100) COLLATE utf16_unicode_ci NOT NULL,
|
||||
`id_theme` int(10) unsigned NOT NULL,
|
||||
`require` varchar(100) COLLATE utf16_unicode_ci NOT NULL,
|
||||
`level` tinyint(4) NOT NULL,
|
||||
`points` smallint(6) NOT NULL,
|
||||
`statement` text COLLATE utf16_unicode_ci NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf16 COLLATE=utf16_unicode_ci AUTO_INCREMENT=1 ;
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf16 COLLATE=utf16_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la table `exercice_dependancies`
|
||||
-- Structure de la table `exercice_files`
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `exercice_dependancies` (
|
||||
CREATE TABLE IF NOT EXISTS `exercice_files` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`id_exercice` int(10) unsigned NOT NULL,
|
||||
`id_dependence` int(10) unsigned NOT NULL,
|
||||
`path` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf16 COLLATE=utf16_unicode_ci AUTO_INCREMENT=1 ;
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la table `exercice_keys`
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `exercice_keys` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`format` enum('raw','md5','sha1','sha256','sha512','whirlpool') COLLATE utf8_unicode_ci NOT NULL,
|
||||
`value` varbinary(100) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
@ -51,11 +67,11 @@ CREATE TABLE IF NOT EXISTS `sessions` (
|
||||
`uid` binary(16) NOT NULL,
|
||||
`time` int(11) NOT NULL,
|
||||
`ip` varbinary(16) NOT NULL,
|
||||
`var` varchar(9999) COLLATE utf16_unicode_ci NOT NULL,
|
||||
`var` varchar(9999) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`level` tinyint(2) NOT NULL,
|
||||
`active` enum('1','0') COLLATE utf16_unicode_ci NOT NULL,
|
||||
`active` enum('1','0') COLLATE utf8_unicode_ci NOT NULL,
|
||||
PRIMARY KEY (`session`)
|
||||
) ENGINE=MEMORY DEFAULT CHARSET=utf16 COLLATE=utf16_unicode_ci;
|
||||
) ENGINE=MEMORY DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
@ -98,4 +114,9 @@ CREATE TABLE IF NOT EXISTS `users` (
|
||||
`lastname` varchar(255) COLLATE utf16_unicode_ci NOT NULL,
|
||||
`company` varchar(255) COLLATE utf16_unicode_ci NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf16 COLLATE=utf16_unicode_ci AUTO_INCREMENT=1 ;
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf16 COLLATE=utf16_unicode_ci AUTO_INCREMENT=2 ;
|
||||
|
||||
|
||||
INSERT INTO users (username, password, auth_level)
|
||||
VALUES
|
||||
("nemunaire", UNHEX('c1d050d16d8c90dae6fef376460299aa8d1cce7c5b299720a8e38952a77212f1019e2cd44ba58e0433c01cb4c81ab9a789c07df218b0b9f05af8d1198a3bd239'), 2);
|
||||
|
3
htdocs/css/errors.css
Normal file
3
htdocs/css/errors.css
Normal file
@ -0,0 +1,3 @@
|
||||
body {
|
||||
padding: 30px;
|
||||
}
|
3
htdocs/css/home.css
Normal file
3
htdocs/css/home.css
Normal file
@ -0,0 +1,3 @@
|
||||
body {
|
||||
padding: 30px;
|
||||
}
|
37
htdocs/css/login.css
Normal file
37
htdocs/css/login.css
Normal file
@ -0,0 +1,37 @@
|
||||
body {
|
||||
padding-top: 40px;
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
.form-signin {
|
||||
max-width: 330px;
|
||||
padding: 15px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.form-signin .form-signin-heading,
|
||||
|
||||
.form-signin .checkbox {
|
||||
font-weight: normal;
|
||||
}
|
||||
.form-signin .form-control {
|
||||
position: relative;
|
||||
font-size: 16px;
|
||||
height: auto;
|
||||
padding: 10px;
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.form-signin .form-control:focus {
|
||||
z-index: 2;
|
||||
}
|
||||
.form-signin input[type="text"] {
|
||||
margin-bottom: -1px;
|
||||
border-bottom-left-radius: 0;
|
||||
border-bottom-right-radius: 0;
|
||||
}
|
||||
.form-signin input[type="password"] {
|
||||
margin-bottom: 10px;
|
||||
border-top-left-radius: 0;
|
||||
border-top-right-radius: 0;
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
|
||||
<!ELEMENT title (#PCDATA)>
|
||||
|
||||
<!ELEMENT exercice (title,points,(statement|key|file*))>
|
||||
<!ELEMENT exercice (title,points,statement,key+,file*)>
|
||||
<!ATTLIST exercice id ID #REQUIRED>
|
||||
<!ATTLIST exercice level (sandbox|easy|simple|medium|hard|extrem) #REQUIRED>
|
||||
<!ATTLIST exercice depends IDREFS #IMPLIED>
|
||||
@ -14,5 +14,7 @@
|
||||
<!ELEMENT statement (#PCDATA)>
|
||||
|
||||
<!ELEMENT key (#PCDATA)>
|
||||
<!ATTLIST key format (raw|md5|sha1|sha256|sha512|whirlpool) "sha512">
|
||||
|
||||
<!ELEMENT file (#PCDATA)>
|
||||
<!ATTLIST file path CDATA #REQUIRED>
|
||||
|
@ -3,7 +3,7 @@
|
||||
require_once(trim(file_get_contents('./.onyx')));
|
||||
|
||||
//On active le débogage si l'on est sur le domaine de debug
|
||||
if ($_SERVER["SERVER_NAME"] == "localhost" || $_SERVER["SERVER_NAME"] == "fic.nemunai.re")
|
||||
if ($_SERVER["SERVER_NAME"] == "localhost" || $_SERVER["SERVER_NAME"] == "fic" || $_SERVER["SERVER_NAME"] == "atlantis.chen.li")
|
||||
define("DEBUG", true);
|
||||
|
||||
//Chargement de tout le nécessaire pour le site
|
||||
@ -119,7 +119,7 @@ if (empty($page)) // Public pages
|
||||
{
|
||||
case "":
|
||||
$_GET["p"] = "";
|
||||
case "login":
|
||||
case "home":
|
||||
include("public/home.php");
|
||||
break;
|
||||
|
||||
@ -127,6 +127,10 @@ if (empty($page)) // Public pages
|
||||
include("public/login.php");
|
||||
break;
|
||||
|
||||
case "score":
|
||||
include("public/score.php");
|
||||
break;
|
||||
|
||||
case "forgotpasswd":
|
||||
include("public/forgotpasswd.php");
|
||||
break;
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
function mdp($username, $mdp)
|
||||
{
|
||||
return hash('whirlpool', strtoupper($username).':'.$mdp);
|
||||
return hash('whirlpool', strtoupper($username).'#'.$mdp);
|
||||
}
|
||||
|
||||
function ip()
|
||||
|
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}
|
Loading…
Reference in New Issue
Block a user