From 54f9ecb7abd82efda81288c74c93d41d6abb5856 Mon Sep 17 00:00:00 2001 From: JunkJumper Date: Wed, 3 Jul 2019 17:40:12 +0200 Subject: [PATCH] update file to remove @override database adress --- Website Source Code/about.php | 12 ++--- Website Source Code/auto.php | 67 +++++++++++++++++----------- Website Source Code/display-lux.php | 7 ++- Website Source Code/display-vent.php | 8 ++-- Website Source Code/ecriture.php | 9 ++-- Website Source Code/get_sql.php | 9 ++-- Website Source Code/index.php | 11 +++-- Website Source Code/send_sql.php | 10 ++--- 8 files changed, 75 insertions(+), 58 deletions(-) diff --git a/Website Source Code/about.php b/Website Source Code/about.php index d78bb13..d2f9ff0 100644 --- a/Website Source Code/about.php +++ b/Website Source Code/about.php @@ -57,13 +57,13 @@
  • Location : Drap, France
  • Contact : contact@junkjumper-projects.com
  • -
  • PDF presentations pages (french only & only by downbloading) : +
  • PDF presentations pages (french only) :
  • @@ -91,4 +91,4 @@ - + \ No newline at end of file diff --git a/Website Source Code/auto.php b/Website Source Code/auto.php index 790b342..bfad479 100644 --- a/Website Source Code/auto.php +++ b/Website Source Code/auto.php @@ -1,13 +1,19 @@ setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + $conn1 = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password); + // set the PDO error mode to exception + $conn1->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + $conn2 = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password); + // set the PDO error mode to exception + $conn2->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // Connection MySQL for imgs displaying. $bdd = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password); @@ -28,9 +34,20 @@ try { $conn = null; +//Simulation of Arduino sensors reception +$randl = rand(0, 9999); +$randw = rand(0, 50); + +//send generated numbers to database +$sql1 = "UPDATE `capteurs` SET `lux` = '$randl' WHERE `capteurs`.`id` = 1"; +$stmt = $conn1->prepare($sql1); +$stmt->execute(); + +$sql2 = "UPDATE `capteurs` SET `vent` = '$randw' WHERE `capteurs`.`id` = 1"; +$stmt2 = $conn2->prepare($sql2); +$stmt2->execute(); ?> - @@ -47,7 +64,7 @@ $conn = null;
    @@ -80,15 +97,15 @@ $conn = null;
      - +
    • query('SELECT `eInt` FROM `capteurs` WHERE id=1'); + $etateInt = $bdd->query('SELECT `lux` FROM `capteurs` WHERE id=1'); $result = $etateInt->fetch(); $count = $result[0]; - if ($count == 1) + if ($count < 3000) { echo ''; } @@ -98,7 +115,7 @@ $conn = null; } ?>
      -

      State of the Indoor Lights

      +

      Position of the blind

      @@ -106,14 +123,14 @@ $conn = null; -
    • -
      +
    • +
      query('SELECT `Store` FROM `capteurs` WHERE id=1'); + $etatStore = $bdd->query('SELECT `vent` FROM `capteurs` WHERE id=1'); $result2 = $etatStore->fetch(); $count2 = $result2[0]; - if ($count2 == 0) + if ($count2 < 30) { echo 'Store en position Haute'; } @@ -123,7 +140,7 @@ $conn = null; } ?>
      -

      Position of the blind

      +

      State of the Outdoor Lights

      @@ -136,10 +153,10 @@ $conn = null;
      query('SELECT `eExt` FROM `capteurs` WHERE id=1'); + $etateExt = $bdd->query('SELECT `lux` FROM `capteurs` WHERE id=1'); $result1 = $etateExt->fetch(); $count1 = $result1[0]; - if ($count1 == 1) + if ($count1 < 3000) { echo ''; } @@ -158,13 +175,13 @@ $conn = null; -
    • +
    • -

      Amount of light (in µW/cm²)

      +

      Amount of light (in µW/cm²)

    • @@ -175,21 +192,21 @@ $conn = null; -
    • +
    • -

      Wind Speed (km/h)

      +

      Wind Speed (km/h)

    • @@ -200,7 +217,7 @@ $conn = null;
      -
      +
      • © 2018 SLEGPI. Projet SIN 2017/2018.

      • Licence Creative Commons This page is available under the terms of the Creative Commons Attribution 4.0 International License.

      • diff --git a/Website Source Code/display-lux.php b/Website Source Code/display-lux.php index 9f0fc7b..b45d634 100644 --- a/Website Source Code/display-lux.php +++ b/Website Source Code/display-lux.php @@ -1,8 +1,7 @@ - - @@ -341,3 +339,4 @@ $conn = null;
      + diff --git a/Website Source Code/send_sql.php b/Website Source Code/send_sql.php index 51e424c..8755eb7 100644 --- a/Website Source Code/send_sql.php +++ b/Website Source Code/send_sql.php @@ -2,10 +2,11 @@ if (isset($_POST["LI"])) $LI= $_POST["LI"]; else $LI =""; if (isset($_POST["LE"])) $LE= $_POST["LE"]; else $LE =""; if (isset($_POST["S"])) $S= $_POST["S"]; else $S =""; -$servername = "localhost"; -$username = "root"; -$password = "root"; -$dbname = "database"; + + +include 'database.php'; + + try { $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password); @@ -68,7 +69,6 @@ $conn = null;

      - For Indoor Lights =

      - For Outdoor Lights =

      - For the blind =

      -