Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Projet ISIS
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MARQUE Pierre
Projet ISIS
Commits
6f25c801
Commit
6f25c801
authored
May 03, 2022
by
Okthane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Vesrion finale - Nouveaux commentaires
parent
287148b5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
40 deletions
+31
-40
index.php
index.php
+1
-9
io.php
io.php
+5
-1
script.js
script.js
+22
-25
upload.php
upload.php
+3
-5
No files found.
index.php
View file @
6f25c801
...
@@ -81,13 +81,13 @@
...
@@ -81,13 +81,13 @@
<!-- <label for="fileUpload">Fichier:</label> -->
<!-- <label for="fileUpload">Fichier:</label> -->
<div
class=
"div-btn-form"
>
<div
class=
"div-btn-form"
>
<input
type=
"file"
name=
"photo"
id=
"fileUpload"
required=
"required"
class=
"btn-form"
accept=
"image/png, image/jpeg"
>
<input
type=
"file"
name=
"photo"
id=
"fileUpload"
required=
"required"
class=
"btn-form"
accept=
"image/png, image/jpeg"
>
<!-- <button onclick="defaultBtnActive()" class="btn-form" id="custom-fileUpload">Choisissez une photo</button> -->
</div>
</div>
<div
class=
"div-btn-form"
>
<div
class=
"div-btn-form"
>
<input
id=
"btnSubmit"
type=
"submit"
name=
"submit"
value=
"Vérifier"
class=
"btn btn-secondary"
style=
"background-color:#00b8de;width: 50%"
>
<input
id=
"btnSubmit"
type=
"submit"
name=
"submit"
value=
"Vérifier"
class=
"btn btn-secondary"
style=
"background-color:#00b8de;width: 50%"
>
</div>
</div>
</form>
</form>
<script>
<script>
/**Ce script affiche la photo téléchargée sans */
const
inpFile
=
document
.
getElementById
(
"fileUpload"
);
const
inpFile
=
document
.
getElementById
(
"fileUpload"
);
const
previewImage
=
document
.
getElementById
(
"img-ID"
);
const
previewImage
=
document
.
getElementById
(
"img-ID"
);
...
@@ -101,7 +101,6 @@
...
@@ -101,7 +101,6 @@
base64
=
get_base64
(
this
.
result
);
base64
=
get_base64
(
this
.
result
);
});
});
reader
.
readAsDataURL
(
file
);
reader
.
readAsDataURL
(
file
);
// findFaces("img-ID");
}
}
inpFile
.
addEventListener
(
"change"
,
function
(){
inpFile
.
addEventListener
(
"change"
,
function
(){
const
file
=
inpFile
.
files
[
0
];
const
file
=
inpFile
.
files
[
0
];
...
@@ -114,16 +113,9 @@
...
@@ -114,16 +113,9 @@
base64
=
get_base64
(
this
.
result
);
base64
=
get_base64
(
this
.
result
);
});
});
reader
.
readAsDataURL
(
file
);
reader
.
readAsDataURL
(
file
);
// findFaces("img-ID");
}
}
});
});
// const defaultBtn = document.querySelector('#fileUpload');
// const customBtn = document.querySelector("#custom-fileUpload");
// function defaultBtnActive(){
// defaultBtn.click();
// }
</script>
</script>
<script
src=
"script.js"
></script>
<script
src=
"script.js"
></script>
</div>
</div>
...
...
io.php
View file @
6f25c801
<?php
<?php
// Fausse API qui reçoit le choix du mail
echo
json_encode
(
'ok'
);
echo
json_encode
(
'ok'
);
?>
\ No newline at end of file
//TODO
?>
script.js
View file @
6f25c801
...
@@ -16,7 +16,6 @@ const idConsole = "span-status"; var Console;
...
@@ -16,7 +16,6 @@ const idConsole = "span-status"; var Console;
var
base64
=
""
;
var
base64
=
""
;
const
idFileUpload
=
"fileUpload"
;
var
inputFileUpload
;
const
idFileUpload
=
"fileUpload"
;
var
inputFileUpload
;
const
idCustomFileUpload
=
"custom-fileUpload"
;
var
btnCustomFileUpload
;
const
idBtnSubmit
=
"btnSubmit"
;
var
btnSubmit
;
const
idBtnSubmit
=
"btnSubmit"
;
var
btnSubmit
;
const
idStatut
=
"span-status"
;
const
idStatut
=
"span-status"
;
...
@@ -38,7 +37,6 @@ $(document).ready(function(){
...
@@ -38,7 +37,6 @@ $(document).ready(function(){
//Variables des éléments du DOM.
//Variables des éléments du DOM.
inputFileUpload
=
$
(
"#"
+
idFileUpload
);
inputFileUpload
=
$
(
"#"
+
idFileUpload
);
btnCustomFileUpload
=
$
(
"#"
+
idCustomFileUpload
);
Img
=
$
(
"#"
+
ID
);
Img
=
$
(
"#"
+
ID
);
ImgBG
=
$
(
"#"
+
ID_bg
);
ImgBG
=
$
(
"#"
+
ID_bg
);
...
@@ -50,7 +48,6 @@ $(document).ready(function(){
...
@@ -50,7 +48,6 @@ $(document).ready(function(){
li_taille
=
$
(
"#"
+
id_li_taille
);
li_taille
=
$
(
"#"
+
id_li_taille
);
//Récupération des données concernant l'étudiant & proposition des différentes addresses mail.
//Récupération des données concernant l'étudiant & proposition des différentes addresses mail.
studentId
=
getParameter
(
window
.
location
.
href
);
studentId
=
getParameter
(
window
.
location
.
href
);
$
.
ajax
({
$
.
ajax
({
...
@@ -60,16 +57,16 @@ $(document).ready(function(){
...
@@ -60,16 +57,16 @@ $(document).ready(function(){
dataType
:
"json"
dataType
:
"json"
})
})
.
done
(
function
(
response
){
.
done
(
function
(
response
){
// let data = JSON.stringify(response);
// $("div#res").append(data);
const
data
=
response
;
// if(!data["atraiter"]){window.open(URL_END, '_self');
let
data
=
response
;
if
(
!
data
[
"atraiter"
]){
window
.
open
(
URL_END
,
'_self'
);}
if
(
!
data
[
"atraiter"
]){
window
.
open
(
URL_END
,
'_self'
);}
console
.
log
(
data
);
console
.
log
(
data
);
let
prenom
=
data
[
'prenom'
];
const
prenom
=
data
[
'prenom'
];
let
nom
=
data
[
'nom'
];
const
nom
=
data
[
'nom'
];
let
mailCalcule
=
data
[
"mailCalcule"
];
const
mailCalcule
=
data
[
"mailCalcule"
];
let
mailsPossibles
=
data
[
"mailsPossibles"
];
const
mailsPossibles
=
data
[
"mailsPossibles"
];
/**Création du choix d'emails (si choix ) */
if
(
mailsPossibles
.
length
!=
0
)
if
(
mailsPossibles
.
length
!=
0
)
{
{
...
@@ -137,7 +134,8 @@ $(document).ready(function(){
...
@@ -137,7 +134,8 @@ $(document).ready(function(){
// La photo se nomme avec l'ID.
// La photo se nomme avec l'ID.
const
formData
=
new
FormData
();
const
formData
=
new
FormData
();
formData
.
set
(
"photo"
,
file
,
studentId
+
"."
+
extension
);
//On modifie le nom de la photo -> ID de l'étudiant
formData
.
set
(
"photo"
,
file
,
studentId
+
"."
+
extension
);
//Requête pour vérifier l'intégrité du fichier, ses dimensions
//Requête pour vérifier l'intégrité du fichier, ses dimensions
...
@@ -179,14 +177,16 @@ $(document).ready(function(){
...
@@ -179,14 +177,16 @@ $(document).ready(function(){
// FONCTIONS ================================================================================
// FONCTIONS ================================================================================
/**
* Requête pour envoyer le mail choisi
*/
function
sendMail
(){
function
sendMail
(){
let
mail
=
$
(
"input[name=
\"
mail
\"
]:checked"
).
val
();
let
mail
=
$
(
"input[name=
\"
mail
\"
]:checked"
).
val
();
console
.
log
(
"unSeulVisage: "
+
unSeulVisage
+
"
\n
format_correct: "
+
format_correct
);
console
.
log
(
"unSeulVisage: "
+
unSeulVisage
+
"
\n
format_correct: "
+
format_correct
);
if
(
unSeulVisage
&&
format_correct
){
if
(
unSeulVisage
&&
format_correct
){
$
.
ajax
({
$
.
ajax
({
url
:
URL_CHOOSE_MAIL
,
url
:
URL_CHOOSE_MAIL
,
//=io.php
method
:
'POST'
,
method
:
'POST'
,
data
:
'mail='
+
mail
,
data
:
'mail='
+
mail
,
...
@@ -205,7 +205,7 @@ async function photoDetourage(formData){
...
@@ -205,7 +205,7 @@ async function photoDetourage(formData){
if
(
unSeulVisage
){
if
(
unSeulVisage
){
$
.
ajax
({
$
.
ajax
({
//url de la requête
//url de la requête
url
:
URL_DETOURAGE
,
url
:
URL_DETOURAGE
,
//=removeBackGround2.php
method
:
'POST'
,
method
:
'POST'
,
enctype
:
'multipart/form-data'
,
enctype
:
'multipart/form-data'
,
data
:
formData
,
data
:
formData
,
...
@@ -216,7 +216,6 @@ async function photoDetourage(formData){
...
@@ -216,7 +216,6 @@ async function photoDetourage(formData){
processData
:
false
processData
:
false
})
})
.
done
(
function
(
data
){
.
done
(
function
(
data
){
console
.
log
(
data
);
//Affichage de la photo
//Affichage de la photo
ImgBG
.
attr
(
'src'
,
data
[
'src'
]);
ImgBG
.
attr
(
'src'
,
data
[
'src'
]);
})
})
...
@@ -227,11 +226,10 @@ async function findFaces(idImage) {
...
@@ -227,11 +226,10 @@ async function findFaces(idImage) {
// btnCustomFileUpload.prop('disabled',true);
// btnCustomFileUpload.prop('disabled',true);
$
(
"body"
).
css
(
"cursor"
,
"wait"
);
$
(
"body"
).
css
(
"cursor"
,
"wait"
);
btnSubmit
.
prop
(
'disabled'
,
true
);
btnSubmit
.
prop
(
'disabled'
,
true
);
const
model
=
await
blazeface
.
load
();
const
model
=
await
blazeface
.
load
();
// const img = ID;
const
img
=
document
.
getElementById
(
idImage
);
const
img
=
document
.
getElementById
(
idImage
);
const
returnTensors
=
false
;
var
returnTensors
=
false
;
const
predictions
=
await
model
.
estimateFaces
(
img
,
returnTensors
);
const
predictions
=
await
model
.
estimateFaces
(
img
,
returnTensors
);
console
.
log
(
predictions
.
length
+
" visage(s) trouvés."
);
console
.
log
(
predictions
.
length
+
" visage(s) trouvés."
);
if
(
predictions
.
length
>
0
)
{
if
(
predictions
.
length
>
0
)
{
// for (let i = 0; i < predictions.length; i++) {
// for (let i = 0; i < predictions.length; i++) {
...
@@ -259,16 +257,15 @@ async function findFaces(idImage) {
...
@@ -259,16 +257,15 @@ async function findFaces(idImage) {
li_OneFace
.
removeClass
(
"list-group-item-secondary list-group-item-success"
).
addClass
(
"list-group-item-danger"
);
li_OneFace
.
removeClass
(
"list-group-item-secondary list-group-item-success"
).
addClass
(
"list-group-item-danger"
);
}
}
btnSubmit
.
prop
(
'disabled'
,
false
);
btnSubmit
.
prop
(
'disabled'
,
false
);
btnCustomFileUpload
.
prop
(
'disabled'
,
false
);
$
(
"body"
).
css
(
"cursor"
,
""
);
$
(
"body"
).
css
(
"cursor"
,
""
);
}
}
function
getParameter
(
url
){
function
getParameter
(
url
){
L
=
url
.
length
;
let
L
=
url
.
length
;
l
=
0
;
l
et
l
=
0
;
parameter
=
""
;
parameter
=
""
;
for
(
var
k
=
0
;
k
<
L
;
k
++
){
for
(
var
k
=
0
;
k
<
L
;
k
++
){
l
=
k
l
=
k
if
(
url
[
k
]
==
"?"
){
break
;}
if
(
url
[
k
]
==
"?"
){
break
;}
}
}
while
(
url
[
l
]
!=
"="
)
while
(
url
[
l
]
!=
"="
)
...
...
upload.php
View file @
6f25c801
<?php
<?php
//dossier temporaitre pour les images
define
(
'PATH_TO_TEMP'
,
"temp"
);
// Vérifier si le formulaire a été soumis
// Vérifier si le formulaire a été soumis
if
(
$_SERVER
[
"REQUEST_METHOD"
]
==
"POST"
)
if
(
$_SERVER
[
"REQUEST_METHOD"
]
==
"POST"
)
{
{
...
@@ -29,7 +26,8 @@ if($_SERVER["REQUEST_METHOD"] == "POST")
...
@@ -29,7 +26,8 @@ if($_SERVER["REQUEST_METHOD"] == "POST")
$ext
=
pathinfo
(
$filename
,
PATHINFO_EXTENSION
);
$ext
=
pathinfo
(
$filename
,
PATHINFO_EXTENSION
);
if
(
array_key_exists
(
$ext
,
$allowed
))
//die("Erreur : Veuillez sélectionner un format de fichier valide.");
if
(
array_key_exists
(
$ext
,
$allowed
))
//die("Erreur : Veuillez sélectionner un format de fichier valide.");
{
{
// Vérifie le type MIME du fichier ATTENTION - VERIFIE SEULEMENT L'EXTENSION
// Vérifie le type MIME du fichier ATTENTION - VERIFIE SEULEMENT L'EXTENSION : En réalité le fichier n'est jamais
// téléchargé sur quelconque serveur, donc ce n'est pas grave.
if
(
in_array
(
$filetype
,
$allowed
))
if
(
in_array
(
$filetype
,
$allowed
))
{
{
$errorMIME
=
false
;
$errorMIME
=
false
;
...
@@ -46,7 +44,7 @@ if($_SERVER["REQUEST_METHOD"] == "POST")
...
@@ -46,7 +44,7 @@ if($_SERVER["REQUEST_METHOD"] == "POST")
"errorMIME"
=>
$errorMIME
,
"errorMIME"
=>
$errorMIME
,
"errorSize"
=>
$errorSize
,
"errorSize"
=>
$errorSize
,
"error"
=>
$error
,
//<----- Prend la valeur true (erreur!) ou false (ouf!)
"error"
=>
$error
,
//<----- Prend la valeur true (erreur!) ou false (ouf!)
);
);
echo
json_encode
(
$data
);
echo
json_encode
(
$data
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment