forked from rebillar/site-accueil-insa
test ville
This commit is contained in:
parent
8255424f87
commit
ae99244e15
1 changed files with 65 additions and 53 deletions
118
admin/ville.php
118
admin/ville.php
|
@ -11,63 +11,72 @@ if($user['perm'] < 1) {
|
|||
|
||||
|
||||
// ajout d'une epreuve
|
||||
if(isset($_POST['add_epreuve'])){
|
||||
|
||||
//$upload_state prend plusieurs valeurs :
|
||||
// 1 si tout est valide et l'image n'existe pas déjà
|
||||
// 0 si une verification a invalidé le fichier
|
||||
// 2 si l'image existe déjà mais l'upload est valide, on va alors utiliser le nom pour la bdd
|
||||
if($_FILES["file"]["error"] != 0){
|
||||
$EXT_WHITELIST = array("gif","jpg","jpeg","raw","png","svg");
|
||||
//$upload_state prend plusieurs valeurs :
|
||||
// 1 si tout est valide et l'image n'existe pas déjà
|
||||
// 0 si une verification a invalidé le fichier
|
||||
// 2 si l'image existe déjà mais l'upload est valide, on va alors utiliser le nom pour la bdd
|
||||
if($_FILES["file"]["error"] != 0){
|
||||
$EXT_WHITELIST = array("gif","jpg","jpeg","raw","png","svg");
|
||||
|
||||
/* gestion des uploads d'images indices */
|
||||
$target_dir = "../assets/img/com_ville/";
|
||||
$target_file = $target_dir . basename($_FILES["photo"]["name"]);
|
||||
$upload_state = 1;
|
||||
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
|
||||
// Check if image file is a actual image or fake image
|
||||
$check = $_FILES["photo"]["size"] > pow(2,2);;
|
||||
if($check !== false) {
|
||||
/* gestion des uploads d'images indices */
|
||||
$target_dir = "../assets/img/com_ville/";
|
||||
$target_file = $target_dir . basename($_FILES["photo"]["name"]);
|
||||
$upload_state = 1;
|
||||
} else {
|
||||
$upload_state = 0;
|
||||
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
|
||||
// Check if image file is a actual image or fake image
|
||||
$check = $_FILES["photo"]["size"] > pow(2,2);;
|
||||
if($check !== false) {
|
||||
$upload_state = 1;
|
||||
} else {
|
||||
$upload_state = 0;
|
||||
}
|
||||
|
||||
if (file_exists($target_file)) {
|
||||
$upload_state = 2;
|
||||
}
|
||||
|
||||
// limite de taille
|
||||
if ($_FILES["photo"]["size"] > pow(2,40)) {
|
||||
$upload_state = 0;
|
||||
}
|
||||
|
||||
// check le type de fichier
|
||||
if (!in_array($imageFileType,$EXT_WHITELIST)){
|
||||
$upload_state = 0;
|
||||
}
|
||||
|
||||
echo $target_file;
|
||||
|
||||
$file_name = "";
|
||||
switch($upload_state){
|
||||
case 1:
|
||||
|
||||
move_uploaded_file($_FILES["photo"]["tmp_name"],$target_file);
|
||||
$file_name = htmlspecialchars($_FILES["photo"]["name"]);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
move_uploaded_file($_FILES["photo"]["tmp_name"],$target_file);
|
||||
$file_name = htmlspecialchars($_FILES["photo"]["name"]);
|
||||
break;
|
||||
case 0:
|
||||
?> <script>
|
||||
alert("L'image envoyée n'a pas passées tout les tests de vérifications.");
|
||||
</script>
|
||||
<?php
|
||||
break;
|
||||
}
|
||||
}else{
|
||||
?>
|
||||
<script>
|
||||
alert("L'image envoyée n'a pas passées tout les tests de vérifications.");
|
||||
echo $_FILES["file"]["error"];
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
if (file_exists($target_file)) {
|
||||
$upload_state = 2;
|
||||
}
|
||||
|
||||
// limite de taille
|
||||
if ($_FILES["photo"]["size"] > pow(2,40)) {
|
||||
$upload_state = 0;
|
||||
}
|
||||
|
||||
// check le type de fichier
|
||||
if (!in_array($imageFileType,$EXT_WHITELIST)){
|
||||
$upload_state = 0;
|
||||
}
|
||||
|
||||
echo $target_file;
|
||||
|
||||
$file_name = "";
|
||||
switch($upload_state){
|
||||
case 1:
|
||||
|
||||
move_uploaded_file($_FILES["photo"]["tmp_name"],$target_file);
|
||||
$file_name = htmlspecialchars($_FILES["photo"]["name"]);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
move_uploaded_file($_FILES["photo"]["tmp_name"],$target_file);
|
||||
$file_name = htmlspecialchars($_FILES["photo"]["name"]);
|
||||
break;
|
||||
case 0:
|
||||
?> <script>
|
||||
alert("L'image envoyée n'a pas passées tout les tests de vérifications.");
|
||||
</script>
|
||||
<?php
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$_POST['est_finale'] = $_POST['est_finale'] == 'on' ? 1 : 0;
|
||||
|
||||
|
@ -84,6 +93,9 @@ if($_FILES["file"]["error"] != 0){
|
|||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//ajout d'une equipe
|
||||
if(isset($_POST['add_equipe'])){
|
||||
$req = $db->prepare("INSERT INTO ville_equipe(nom,temps) VALUES(?,?)");
|
||||
|
|
Loading…
Reference in a new issue