diff --git a/index.php b/index.php index 8c8d1b1..462837c 100755 --- a/index.php +++ b/index.php @@ -6,14 +6,18 @@ error_reporting(E_ALL); session_start(); +if(isset($_POST["sessionDestroy"])) +{ + session_destroy(); + header('Location: index.php'); +} + if(!isset($_SESSION["sl"])) { $_SESSION["sl"] = "1"; $_SESSION["login"] = ""; } - require_once SITE_ROOT.'/vendor/autoload.php'; - $loader = new Twig_Loader_Filesystem( SITE_ROOT.'/views'); $twig = new Twig_Environment($loader, array( 'cache' => /*SITE_ROOT.'/twig/compilation_cache'*/false, diff --git a/post.php b/post.php index 123c0fc..b571265 100755 --- a/post.php +++ b/post.php @@ -7,6 +7,7 @@ if (session_status() == PHP_SESSION_NONE) { $emailPatern = '/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/'; $pwPatern = '/^[a-z]{8,16}$/'; $loginPatern = '/^[a-z]{8,16}$/'; +$datePatern = '/^\d{4}[\/\-](?:\d{1}|1[012]|0\d)[\/\-](?:\d{1}|[123]\d|0\d)/'; $ret["return"] = false; $ret["pw"] = null; try { @@ -36,7 +37,7 @@ elseif (isset($_POST["userExist"])) { //INSERT INTO `projetphp` (`login`, `date_naissance`, `e_mail`, `mot_de_passe`, `security_level`) VALUES ('blipblop', '2019-01-09', 'aaaaa@aaa.cc', MD5('sdfqsdfsfd'), '5'); elseif (isset($_POST["newUser"],$_POST["datene"], $_POST["email"], $_POST["pw"]) && $_POST["newUser"] == "true") { - if(preg_match($loginPatern, $_POST["login"]) && preg_match($emailPatern, $_POST["email"]) && preg_match($pwPatern, $_POST["pw"])) + if(preg_match($loginPatern, $_POST["login"]) && preg_match($emailPatern, $_POST["email"]) && preg_match($pwPatern, $_POST["pw"]) && preg_match($datePatern, $_POST["datene"])) { if(userExist($_POST["login"])) { diff --git a/script/login.js b/script/login.js index 87a9bb9..abe3682 100644 --- a/script/login.js +++ b/script/login.js @@ -8,6 +8,7 @@ $(function() { $('form').on('submit',function(e) { e.preventDefault(); var data = $(this).serialize(); + var loginName = $("input[name$='login']", $(this)).val() var url = $(this).attr('action') if(url == "./post.php") if (mailPatern.test($(".email input").val()) && passwordPatern.test($(".pw input").val()) && $(".pw2 input").val() == $(".pw input").val() && loginPatern.test($(".login input").val())) @@ -39,7 +40,7 @@ $(function() { } else if (typeof(data.login) != "undefined" && data.login !== null) { if(data.login) { - swal("Good job!", "You are logged !\nYou're redirect in 5 seconds", "success"); + swal("Good job!", "Welkome "+loginName+"\nYou are logged !\nYou're redirect in 5 seconds", "success"); var delay = 5000; setTimeout(function(){ window.location = "/bil/"; }, delay); } diff --git a/views/table.html.twig b/views/table.html.twig index 560d092..d83031a 100755 --- a/views/table.html.twig +++ b/views/table.html.twig @@ -3,9 +3,13 @@ {% include 'header.html.twig' %} - - + + +
+ + +