diff --git a/control/login.php b/control/login.php index 6545f63..65469de 100755 --- a/control/login.php +++ b/control/login.php @@ -4,21 +4,18 @@ if (session_status() == PHP_SESSION_NONE) { session_start(); } -$template = $twig->load('login.html.twig'); -echo $template->render(array()); - if(isset($_POST["login"], $_POST["pw"])) { try { - $config = include(SITE_ROOT.'config.php'); + $config = include('../config.php'); $bdd = new PDO('mysql:host='.$config['host'].';dbname='.$config['dbName'].';charset=utf8', $config['username'], $config['pw']); } catch (Exception $e) { die('Erreur : '.$e->getMessage()); } $req = $bdd->prepare('SELECT * FROM projetphp WHERE login = ? AND mot_de_passe = ?'); - $req->exexute(array(htmlspecialchars($_POST["login"]),md5($_POST["pw"]))); + $req->execute(array(htmlspecialchars($_POST["login"]),md5($_POST["pw"]))); if($req->rowCount() > 0) { $data = $req->fetch(); @@ -29,5 +26,11 @@ if(isset($_POST["login"], $_POST["pw"])) else echo json_encode((object)array("login"=>false)); } +elseif(isset($twig)) { + $template = $twig->load('login.html.twig'); + + + echo $template->render(array()); +} ?> diff --git a/control/table.php b/control/table.php index a346275..e7b82f4 100755 --- a/control/table.php +++ b/control/table.php @@ -15,6 +15,6 @@ for($i=0;$data = $reponse->fetch();$i++) { $datas[$i] = $data; } $reponse->closeCursor(); -echo $template->render(array('datas' => $datas)); +echo $template->render(array('datas' => $datas, "session" => $_SESSION)); ?> diff --git a/index.php b/index.php index fb20be7..8c8d1b1 100755 --- a/index.php +++ b/index.php @@ -6,6 +6,12 @@ error_reporting(E_ALL); session_start(); +if(!isset($_SESSION["sl"])) +{ + $_SESSION["sl"] = "1"; + $_SESSION["login"] = ""; +} + require_once SITE_ROOT.'/vendor/autoload.php'; $loader = new Twig_Loader_Filesystem( SITE_ROOT.'/views'); @@ -23,12 +29,26 @@ if(isset($_GET["page"])) include './control/login.php'; break; default: - include './control/table.php'; + include './control/login.php'; break; } } else { - include './control/table.php'; + if(isset($_SESSION["sl"])) + switch ($_SESSION["sl"]) { + case '5': + case '10': + include './control/table.php'; + break; + default: + if(!empty($_SESSION["login"])) + include './control/table.php'; + else + include './control/login.php'; + break; + } + else + include './control/login.php'; } diff --git a/login.html b/login.html deleted file mode 100644 index 7d6da45..0000000 --- a/login.html +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - -
-
-
- - - - -

Already registered? Sign In

-
- -
-
- - diff --git a/post.php b/post.php index 74e7cf8..3a3d1c0 100755 --- a/post.php +++ b/post.php @@ -1,5 +1,9 @@ ()\[\]\\.,;:\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}$/'; @@ -40,7 +44,7 @@ elseif (isset($_POST["newUser"],$_POST["datene"], $_POST["email"], $_POST["pw"]) } else { - $sl = isset($_POST["sl"])?$_POST["sl"]:"1"; + $sl = isset($_POST["sl"])?$_POST["sl"]:"5"; $ret["pw"] = md5(htmlspecialchars($_POST["pw"], ENT_QUOTES, 'UTF-8')); $req = $bdd->prepare('INSERT INTO `projetphp` (`login`, `date_naissance`, `e_mail`, `mot_de_passe`, `security_level`) VALUES (:login, :datene, :email, :pw, :slvl)'); $req->execute(array( @@ -70,7 +74,7 @@ else if (isset($_POST["newUser"], $_POST["updatePW"], $_POST["datene"], $_POST[" 'datene' => htmlspecialchars($_POST["datene"], ENT_QUOTES, 'UTF-8'), 'email' => htmlspecialchars($_POST["email"], ENT_QUOTES, 'UTF-8'), 'pw' => md5(htmlspecialchars($_POST["pw"], ENT_QUOTES, 'UTF-8')), -'sl' => htmlspecialchars($_POST["sl"], ENT_QUOTES, 'UTF-8'), +'sl' => ($_SESSION["sl"]=="10"?htmlspecialchars($_POST["sl"], ENT_QUOTES, 'UTF-8'):$_SESSION["sl"]), 'login' => htmlspecialchars($_POST["login"], ENT_QUOTES, 'UTF-8'), )); $req->closeCursor(); @@ -81,7 +85,7 @@ $req->closeCursor(); $req->execute(array( 'datene' => htmlspecialchars($_POST["datene"], ENT_QUOTES, 'UTF-8'), 'email' => htmlspecialchars($_POST["email"], ENT_QUOTES, 'UTF-8'), -'sl' => htmlspecialchars($_POST["sl"], ENT_QUOTES, 'UTF-8'), +'sl' => ($_SESSION["sl"]=="10"?htmlspecialchars($_POST["sl"], ENT_QUOTES, 'UTF-8'):$_SESSION["sl"]), 'login' => htmlspecialchars($_POST["login"], ENT_QUOTES, 'UTF-8'), )); $req->closeCursor(); diff --git a/script.js b/script.js index 97ddf64..4cef3f1 100755 --- a/script.js +++ b/script.js @@ -35,6 +35,13 @@ $(function() { $('div', $(this).parent()).css("display", "block"); } }); + $("body").on("keyup change", ".pw2 input", function() { + if ($(this).val() == $(".pw input").val()) { + $(this).css("background-color", ""); + } else { + $(this).css("background-color", "red"); + } + }); $("body").on("keyup change", ".email input", function() { if (mailPatern.test($(this).val())) { $(this).css("background-color", ""); @@ -151,7 +158,8 @@ $(function() { className = j.attr('class'); if (className == "sl") { val = ltrim(j.html()); - j.html('\ \ \ \ diff --git a/test.php b/test.php deleted file mode 100644 index fb20be7..0000000 --- a/test.php +++ /dev/null @@ -1,35 +0,0 @@ - /*SITE_ROOT.'/twig/compilation_cache'*/false, -)); - -if(isset($_GET["page"])) -{ - switch ($_GET["page"]) { - case 'table': - include './control/table.php'; - break; - case 'login': - include './control/login.php'; - break; - default: - include './control/table.php'; - break; - } -} -else { - include './control/table.php'; -} - - - ?> diff --git a/views/login.html.twig b/views/login.html.twig index 45cb7ce..b6506a8 100755 --- a/views/login.html.twig +++ b/views/login.html.twig @@ -8,7 +8,8 @@
-
+ +
diff --git a/views/table.html.twig b/views/table.html.twig index 065c869..0b16092 100755 --- a/views/table.html.twig +++ b/views/table.html.twig @@ -5,6 +5,7 @@ + @@ -13,7 +14,9 @@ + {% if (session["sl"] == "5" or session["sl"] == "10") %} + {% endif %} @@ -33,13 +36,17 @@ - + {% if (session["sl"] == "5" or session["sl"] == "10") %} + {% endif %} {% endfor %} + {% if (session["sl"] == "10") %} - + {% endif %}
email PW slvl
{{ data["security_level"] }} - {% if ((session["sl"] == "5" and session["login"] == data["login"]) or session["sl"] == "10") %} + + {% endif %} +