Ajout logout + check date php
This commit is contained in:
parent
aca024783e
commit
5ef0b64a60
|
@ -6,14 +6,18 @@ error_reporting(E_ALL);
|
||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
|
if(isset($_POST["sessionDestroy"]))
|
||||||
|
{
|
||||||
|
session_destroy();
|
||||||
|
header('Location: index.php');
|
||||||
|
}
|
||||||
|
|
||||||
if(!isset($_SESSION["sl"]))
|
if(!isset($_SESSION["sl"]))
|
||||||
{
|
{
|
||||||
$_SESSION["sl"] = "1";
|
$_SESSION["sl"] = "1";
|
||||||
$_SESSION["login"] = "";
|
$_SESSION["login"] = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once SITE_ROOT.'/vendor/autoload.php';
|
require_once SITE_ROOT.'/vendor/autoload.php';
|
||||||
|
|
||||||
$loader = new Twig_Loader_Filesystem( SITE_ROOT.'/views');
|
$loader = new Twig_Loader_Filesystem( SITE_ROOT.'/views');
|
||||||
$twig = new Twig_Environment($loader, array(
|
$twig = new Twig_Environment($loader, array(
|
||||||
'cache' => /*SITE_ROOT.'/twig/compilation_cache'*/false,
|
'cache' => /*SITE_ROOT.'/twig/compilation_cache'*/false,
|
||||||
|
|
3
post.php
3
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,}))$/';
|
$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}$/';
|
$pwPatern = '/^[a-z]{8,16}$/';
|
||||||
$loginPatern = '/^[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["return"] = false;
|
||||||
$ret["pw"] = null;
|
$ret["pw"] = null;
|
||||||
try {
|
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');
|
//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") {
|
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"]))
|
if(userExist($_POST["login"]))
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,6 +8,7 @@ $(function() {
|
||||||
$('form').on('submit',function(e) {
|
$('form').on('submit',function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var data = $(this).serialize();
|
var data = $(this).serialize();
|
||||||
|
var loginName = $("input[name$='login']", $(this)).val()
|
||||||
var url = $(this).attr('action')
|
var url = $(this).attr('action')
|
||||||
if(url == "./post.php")
|
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()))
|
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) {
|
} else if (typeof(data.login) != "undefined" && data.login !== null) {
|
||||||
if(data.login)
|
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;
|
var delay = 5000;
|
||||||
setTimeout(function(){ window.location = "/bil/"; }, delay);
|
setTimeout(function(){ window.location = "/bil/"; }, delay);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,13 @@
|
||||||
{% include 'header.html.twig' %}
|
{% include 'header.html.twig' %}
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body><span>
|
||||||
<input type="text" id="myInput" onkeyup="myFunction()" placeholder="Search for login..">
|
<input type="text" id="myInput" style="width:95%" onkeyup="myFunction()" placeholder="Search for login..">
|
||||||
<input type="hidden" id="slVal" value="{{ session["sl"] }}" />
|
<input type="hidden" id="slVal" value="{{ session["sl"] }}" />
|
||||||
|
<form method="post" action="" style="display:inline">
|
||||||
|
<input type="hidden" name="sessionDestroy" value=""/>
|
||||||
|
<button style="float: right;width: 5%;"><i class="fas fa-sign-out-alt fa-2x"></i></button>
|
||||||
|
</form></span>
|
||||||
<table id="allRecord">
|
<table id="allRecord">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
Loading…
Reference in New Issue