diff --git a/admin/com_photo.php b/admin/com_photo.php
new file mode 100644
index 0000000..9b75c65
--- /dev/null
+++ b/admin/com_photo.php
@@ -0,0 +1,114 @@
+ pow(2,6);;
+ if($check !== false) {
+ $upload_state = 1;
+ } else {
+ $upload_state = 0;
+ }
+
+ if (file_exists($target_file)) {
+ $upload_state = 0;
+ }
+
+ // 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;
+ }
+
+ switch($upload_state){
+ case 1:
+ compressImage($_FILES["photo"]["tmp_name"],"../assets/img/com_photo/thumbs/".$_FILES["photo"]["name"],10);
+ move_uploaded_file($_FILES["photo"]["tmp_name"],$target_file);
+ break;
+ case 0:
+ ?>
+
+
+
+
+
+
+ Admin / Com'Photo
+
+
+
+
+
+
+
+ Difficultés pour convertir vos images au bon format ? Essayez Ce site
+
+
+
+
\ No newline at end of file
diff --git a/admin/gestion_des_acces.php b/admin/gestion_des_acces.php
index 1cd35bc..c33995e 100644
--- a/admin/gestion_des_acces.php
+++ b/admin/gestion_des_acces.php
@@ -88,7 +88,7 @@ if(isset($_GET['adm']) AND !empty($_GET['adm']))
if(isset($_POST['send'])) {
if(isset($_POST['pseudo']) AND !empty($_POST['pseudo']) AND isset($_POST['perm']) AND !empty($_POST['perm'])) {
- if($user['perm'] >= 3) {
+ if($user['perm'] >= 4) {
$pseudo = htmlspecialchars($_POST['pseudo']);
$perm = htmlspecialchars($_POST['perm']);
@@ -140,7 +140,7 @@ if(isset($_POST['send'])) {
diff --git a/admin/prototype_com_ville.php b/admin/prototype_com_ville.php
deleted file mode 100644
index 64d3212..0000000
--- a/admin/prototype_com_ville.php
+++ /dev/null
@@ -1,175 +0,0 @@
-
-
-
-
- Title
-
-
-
-
-
-
-
-
-
Equipe 1-1
-
-
-
- ';
- echo $node;
-
- if ($i <= $current) {
- // --:-- doit être remplacé par l'heure à laquelle le point $node a été atteint
- echo '
--:--
';
- }
- echo '
';
-
- if ($i < 17) {
- echo '
';
- if ($i < $current) {
- echo '
--m
'; // --mn doit être remplacé par le deltaT entre les points $node et $node+1
- }
- echo '
';
- }
- }
-
- ?>
-
-
-
-
-
-
-
-
diff --git a/admin/script.php b/admin/script.php
index 5feda42..c8a2d8a 100644
--- a/admin/script.php
+++ b/admin/script.php
@@ -24,17 +24,21 @@ if($user_exist != 1) {
switch ($user['perm']) {
case 1:
- $content = $content."Com'ville";
+ $content = $content."Com'ville"
+ ."Com'Photo";
+
break;
case 2:
$content = $content
."Com'ville"
- .'Planning';
+ .'Planning'
+ ."Com'Photo";
break;
case 3:
$content = $content
."Com'ville"
."Planning"
+ ."Com'Photo"
."Mots croises"
."Gestion des accès"
."Enigma"
diff --git a/admin/ville.php b/admin/ville.php
index b7d193c..adb20b5 100644
--- a/admin/ville.php
+++ b/admin/ville.php
@@ -13,18 +13,76 @@ 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
+
+
+ $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) {
+ $upload_state = 1;
+ } else {
+ $upload_state = 0;
+ }
+
+ if (file_exists($target_file)) {
+ $upload_state = 2;
+ }
+
+ // limite de taille
+ if ($_FILES["photo"]["size"] > pow(2,25)) {
+ $upload_state = 0;
+ }
+
+ // check le type de fichier
+ if (!in_array($imageFileType,$EXT_WHITELIST)){
+ $upload_state = 0;
+ }
+
+ $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:
+ $file_name = htmlspecialchars($_FILES["photo"]["name"]);
+ break;
+ case 0:
+ ?>
+ prepare("INSERT INTO ville_epreuve(indice,reponse,photo,id_equipe,est_finale,ordre,est_trouvee) VALUES(?,?,?,?,?,?,?)");
$req->execute(array(htmlspecialchars($_POST['indice']),
htmlspecialchars($_POST['reponse']),
- htmlspecialchars($_POST['photo']),
+ $file_name,
(int)htmlspecialchars($_POST['id_equipe']),
(bool)htmlspecialchars($_POST['est_finale']),
(int)htmlspecialchars($_POST['ordre']),
false
));
+
+
+
+
}
//ajout d'une equipe
@@ -47,6 +105,11 @@ if(isset($_POST['del_epreuve'])){
}
+
+
+
+
+
?>
@@ -59,12 +122,13 @@ if(isset($_POST['del_epreuve'])){
-