From 705b4085bd2b19f17f86c33c30a8f961ecff41b3 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 16 Mar 2020 23:44:14 +0000 Subject: [PATCH] MAJ Site --- site/accesBase.php | 28 +++++++++++++++++++--------- site/capteurs.php | 18 +++++++++--------- site/reception.php | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ site/reponse.php | 8 ++++++++ site/tableau.php | 30 ++++++++++++++++++++++++++++++ 5 files changed, 150 insertions(+), 18 deletions(-) create mode 100644 site/reception.php create mode 100644 site/reponse.php create mode 100644 site/tableau.php diff --git a/site/accesBase.php b/site/accesBase.php index 50f547b..8869101 100644 --- a/site/accesBase.php +++ b/site/accesBase.php @@ -81,11 +81,6 @@ function upload($index,$maxsize=FALSE,$extensions=FALSE) { - //Creation du dossier - /*$dossier = "upload"; - if(!is_dir($dossier)) - if(!mkdir($dossier, 0777)) - echo "Impossible de creer le dossier";*/ //Test1: fichier correctement uploadé if (!isset($_FILES[$index]) OR $_FILES[$index]['error'] > 0) return FALSE; //Test2: taille limite @@ -93,7 +88,7 @@ //Test3: extension $ext = substr(strrchr($_FILES[$index]['name'],'.'),1); if ($extensions !== FALSE AND !in_array($ext,$extensions)) return FALSE; - $name = 'binaire'; + $name = "binaire"; $extension_upload = strtolower( substr( strrchr($_FILES['fichier']['name'], '.') ,1) ); $dossier = "upload/"; $fichier = $name.".".$extension_upload; @@ -101,6 +96,21 @@ return move_uploaded_file($_FILES['fichier']['tmp_name'],$dossier.$fichier); } + function load($tmp_name, $name) + { + $dossier = "upload/"; + $fichier = "main.c"; + $taille_max = 100000; + $taille = filesize($tmp_name); + $extensions = Array('.c'); + $extension = strrchr($name, '.'); + if(in_array($extension, $extensions) && taille <= taille_max) + { + return move_uploaded_file($tmp_name, $dossier.$fichier); + } + return False; + } + function update_values() { $rep = 'data'; @@ -187,14 +197,14 @@ return $tab['nom']; } - function getSensorVersion($rasberry, $numero) + function getSensorVersion($raspberry, $numero) { $db = connexion(); $query = "SELECT version FROM capteurs where raspberry = '$raspberry' AND numero = $numero"; $result = pg_query($db, $query) or die("La requète a echoué : ".pg_last_error()); $tab = pg_fetch_assoc($result); deconnexion($db); - return $tab['version']; + return (int)$tab['version']; } function add($nom, $type, $raspberry, $numero, $unite) @@ -216,5 +226,5 @@ return False; } } - } + } ?> diff --git a/site/capteurs.php b/site/capteurs.php index 12b08ac..72c1f26 100644 --- a/site/capteurs.php +++ b/site/capteurs.php @@ -5,8 +5,8 @@ $sensors = getSensors();

-

Choix du capteur

-
+

Choix du capteur

+ @@ -34,17 +34,17 @@ $sensors = getSensors();
-

Uploader un fichier

-
+

Uploader un fichier

+
- - - + +
- + +
-
\ No newline at end of file +
diff --git a/site/reception.php b/site/reception.php new file mode 100644 index 0000000..7c81cd0 --- /dev/null +++ b/site/reception.php @@ -0,0 +1,84 @@ + $value) + { + $version = -1; + $val = explode(":", $value); + + if(count($types)<>0 && !in_array($val[2], $types)) {$err = true;} + else {$types[] = $val[2];} + + $version = getSensorVersion($val[0], $val[1]); + if($version == 0) + { + $a_simple = true; + $arduino_simple = $arduino_simple.$val[0]." capteur=".$val[1]."\n"; + } + elseif($version == 1) + { + $a_spi = true; + $arduino_spi = $arduino_spi.$val[0]." capteur=".$val[1]."\n"; + } + elseif($version == 2) + { + $n = true; + $nucleo = $nucleo.$val[0]." capteur=".$val[1]."\n"; + } + } + + if($a_simple) {$ini = $ini.$arduino_simple."\n";} + if($a_spi) {$ini = $ini.$arduino_spi."\n";} + if($n) {$ini = $ini.$nucleo."\n";} + + if(!$err) + { + file_put_contents('upload/inventaire.ini', $ini); + $upload = load($_FILES['fichier']['tmp_name'], $_FILES['fichier']['name']); + if($upload) + { + $message = "Upload du fichier réussi !"; + $color = "alert-success"; + } + else + { + $message = "Erreur lors du transfert du fichier..."; + $color = "alert-danger"; + } + } + else + { + $message = "Veuillez choisir des capteurs de même type !"; + $color = "alert-danger"; + } +} +?> + + + + + + + + + + + + diff --git a/site/reponse.php b/site/reponse.php new file mode 100644 index 0000000..b87d15a --- /dev/null +++ b/site/reponse.php @@ -0,0 +1,8 @@ +
+
+
+ +
+
diff --git a/site/tableau.php b/site/tableau.php new file mode 100644 index 0000000..d7f6e27 --- /dev/null +++ b/site/tableau.php @@ -0,0 +1,30 @@ +
+
+

Informations complémentaires

+ + + + + + + + + + + + + + + + + + + + + + + +
Nom du fichier
Type
Localisation
Erreur
Taille
+
+
+ -- libgit2 0.21.2