Commit 42d1b639 authored by Okthane's avatar Okthane

'final'

parent 62cac6a5
...@@ -8,6 +8,6 @@ ...@@ -8,6 +8,6 @@
<title>Merci pour votre participation</title> <title>Merci pour votre participation</title>
</head> </head>
<body> <body>
<img src="img/.jpg" height="400px" >
</body> </body>
</html> </html>
\ No newline at end of file
File added
...@@ -63,8 +63,8 @@ ...@@ -63,8 +63,8 @@
<div id=conditions class="col-md-3 my-5 d-flex justify-content-center"> <div id=conditions class="col-md-3 my-5 d-flex justify-content-center">
<ul class="list-group"> <ul class="list-group">
<li id="li-oneface" class="list-group-item list-group-item-secondary">Un seul visage<span></span></li> <li id="li-oneface" class="list-group-item list-group-item-secondary">Un seul visage<span></span></li>
<li id="li-format" class="list-group-item list-group-item-secondary">Format (jpg ou png)<span></span></li> <li id="li-format" class="list-group-item list-group-item-secondary">Format (jpg/png)<span></span></li>
<li id="li-size" class="list-group-item list-group-item-secondary">Poids (< 1 Mo)<span></span></li> <li id="li-taille" class="list-group-item list-group-item-secondary">Poids (< 1 Mo)<span></span></li>
</ul> </ul>
</div> </div>
<div class="col-md-3 my-auto d-flex justify-content-center"> <div class="col-md-3 my-auto d-flex justify-content-center">
......
<?php <?php
// phpinfo(); // phpinfo();
// echo json_encode(array("test"=>"ok")); die; // die;
define('WHERE_TO_PUT','img_bg'); define('WHERE_TO_PUT','img_bg');
define('PATH_TO_BG', "img_bg"); define('PATH_TO_BG', "img_bg");
define('TEMP','temp'); define('TEMP','temp');
define('KEY','qtU9bhJqBxu4aYUsjJYJMWXC'); define('KEY','qtU9bhJqBxu4aYUsjJYJMWXC');
require_once "vendor/autoload.php"; require_once "vendor/autoload.php";
if($_SERVER["REQUEST_METHOD"] == "POST") if($_SERVER["REQUEST_METHOD"] == "POST")
{ {
if(isset($_FILES["photo"]) && $_FILES["photo"]["error"] == 0) if(isset($_FILES["photo"]) && $_FILES["photo"]["error"] == 0)
...@@ -44,11 +44,11 @@ if($_SERVER["REQUEST_METHOD"] == "POST") ...@@ -44,11 +44,11 @@ if($_SERVER["REQUEST_METHOD"] == "POST")
// $deletefile=unlink(TEMP.'/'.$newfilename); // $deletefile=unlink(TEMP.'/'.$newfilename);
//On crée et stocke l'image détourée //On crée et stocke l'image détourée
$fp = fopen('img_bg/'.pathinfo($newfilename, PATHINFO_FILENAME)."NO-BG.png", "wb"); $fp = fopen('img_bg/'.pathinfo($newfilename, PATHINFO_FILENAME).".png", "wb");
fwrite($fp, $res->getBody()); fwrite($fp, $res->getBody());
fclose($fp); fclose($fp);
$path = 'img_bg/'.pathinfo($filename, PATHINFO_FILENAME)."NO-BG.png"; $path = 'img_bg/'.pathinfo($filename, PATHINFO_FILENAME).".png";
$type = pathinfo($path, PATHINFO_EXTENSION); $type = pathinfo($path, PATHINFO_EXTENSION);
$data = file_get_contents($path); $data = file_get_contents($path);
$base64 = 'data:image/' . $type . ';base64,' . base64_encode($data); $base64 = 'data:image/' . $type . ';base64,' . base64_encode($data);
......
...@@ -33,8 +33,8 @@ var errorRemoveBackGround = true; ...@@ -33,8 +33,8 @@ var errorRemoveBackGround = true;
var unSeulVisage = false; var unSeulVisage = false;
var format_correct = false; var format_correct = false;
const id_li_OneFace = "li-oneface"; var li_OneFace; const id_li_OneFace = "li-oneface"; var li_OneFace;
const id_li_Format = "li-oneface"; var li_format; const id_li_format = "li-format"; var li_format;
const id_li_taille = "li-oneface"; var li_taille; const id_li_taille = "li-taille"; var li_taille;
// SCRIPT ==================================================================================== // SCRIPT ====================================================================================
...@@ -60,12 +60,18 @@ $(document).ready(function(){ ...@@ -60,12 +60,18 @@ $(document).ready(function(){
inputFileUpload.change(function(){ inputFileUpload.change(function(){
unSeulVisage=false; unSeulVisage=false;
format_correct=false; format_correct=false;
valide=false;
ImgBG.attr("src",""); ImgBG.attr("src","");
li_format.removeClass("list-group-item-success list-group-item-danger").addClass("list-group-item-secondary");
li_OneFace.removeClass(" list-group-item-success list-group-item-danger").addClass("list-group-item-secondary");
li_taille.removeClass(" list-group-item-success list-group-item-danger").addClass("list-group-item-secondary");
}); });
//Requête pour les vérifications de sécurité & de format //Requête pour les vérifications de sécurité & de format
$("#form").on("submit",function (event) { $("#form").on("submit",function (event) {
event.preventDefault(); if(valide==false)
{ event.preventDefault();
var formData = new FormData(this); var formData = new FormData(this);
console.log(inputFileUpload.attr('filename')); console.log(inputFileUpload.attr('filename'));
...@@ -89,15 +95,16 @@ $(document).ready(function(){ ...@@ -89,15 +95,16 @@ $(document).ready(function(){
.done(function(data){ .done(function(data){
errorFormat = data['error']; errorFormat = data['error'];
data['errorMIME']?li_format.removeClass("list-group-item-secondary list-group-item-success").addClass("list-group-item-danger"): if(data['errorMIME']){li_format.removeClass("list-group-item-secondary list-group-item-success").addClass("list-group-item-danger");}
li_format.removeClass("list-group-item-secondary list-group-item-danger").addClass("list-group-item-success"); else{li_format.removeClass("list-group-item-secondary list-group-item-danger").addClass("list-group-item-success");}
data['errorSize']?li_taille.removeClass("list-group-item-secondary list-group-item-success").addClass("list-group-item-danger"): console.log(data['errorSize'])
li_taille.removeClass("list-group-item-secondary list-group-item-danger").addClass("list-group-item-success"); if(data['errorSize']){console.log(2); li_taille.removeClass("list-group-item-secondary list-group-item-success").addClass("list-group-item-danger");}
else{console.log(1); li_taille.removeClass("list-group-item-secondary list-group-item-danger").addClass("list-group-item-success");}
if(!errorFormat){ if(!errorFormat){
format_correct = true; format_correct = true;
photoDetourage(formData); photoDetourage(formData);
} }
}) })}
}); });
...@@ -112,9 +119,9 @@ $(document).ready(function(){ ...@@ -112,9 +119,9 @@ $(document).ready(function(){
.done(function(response){ .done(function(response){
// let data = JSON.stringify(response); // let data = JSON.stringify(response);
// $("div#res").append(data); // $("div#res").append(data);
if(!data["atraiter"]){window.open(URL_END, '_self');
let data = response; let data = response;
console.log(data); console.log(data);
let studentIdRes = data['studentId'];
let prenom = data['prenom']; let prenom = data['prenom'];
let nom = data['nom']; let nom = data['nom'];
let mailCalcule = data["mailCalcule"]; let mailCalcule = data["mailCalcule"];
...@@ -203,9 +210,9 @@ function sendMail(){ ...@@ -203,9 +210,9 @@ function sendMail(){
} }
async function photoDetourage(formData){ async function photoDetourage(formData){
// await findFaces(ID); await findFaces(ID);
// if(unSeulVisage){ if(unSeulVisage){
if (true){ // if (true){
$.ajax({ $.ajax({
//url de la requête //url de la requête
url: URL_DETOURAGE, url: URL_DETOURAGE,
...@@ -213,8 +220,9 @@ async function photoDetourage(formData){ ...@@ -213,8 +220,9 @@ async function photoDetourage(formData){
method: 'POST', method: 'POST',
enctype: 'multipart/form-data', enctype: 'multipart/form-data',
data: formData, data: formData,
cache: false,
cache: false,
dataType: "json", dataType: "json",
contentType: false, contentType: false,
processData: false processData: false
...@@ -294,6 +302,7 @@ function get_base64(src){ ...@@ -294,6 +302,7 @@ function get_base64(src){
k=k+1; k=k+1;
} }
base_64 = string.slice(k+7); base_64 = string.slice(k+7);
console.log(base_64)
return base_64; return base_64;
} }
......
...@@ -37,12 +37,12 @@ if($_SERVER["REQUEST_METHOD"] == "POST") ...@@ -37,12 +37,12 @@ if($_SERVER["REQUEST_METHOD"] == "POST")
} }
} }
$maxsize = 1 * 1024 * 1024; $maxsize = 1 * 1024 * 1024;
if(!($filename > $maxsize)) if(!($filesize > $maxsize))
{ {
$errorSize = false; $errorSize = false;
} }
} }
$error = $errorMIME&&$errorSize; $error = $errorMIME || $errorSize;
$data = array( $data = array(
"errorMIME" => $errorMIME, "errorMIME" => $errorMIME,
......
<?php <?php
if($_SERVER["REQUEST_METHOD"]=="POST"){ if($_SERVER["REQUEST_METHOD"]=="POST"){
$data = array( $data = array(
"dossier_valide" => false, "atraiter" => true,
"studentId" => $_POST['studentId'], "studentId" => $_POST['studentId'],
"prenom" => "jean-patrick", "prenom" => "jean-patrick",
"nom" => "doe.remifa.sollasi", "nom" => "doe.remifa.sollasi",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment