Adding configuration display
authorBrian Flowers <git-admn@bsflowers.net>
Tue, 27 Sep 2016 05:16:32 +0000 (01:16 -0400)
committerBrian Flowers <git-admn@bsflowers.net>
Tue, 27 Sep 2016 05:16:32 +0000 (01:16 -0400)
configure.php

index 562183c..34e2d31 100755 (executable)
@@ -1,3 +1,6 @@
+// /home/bdsm must be bdsm:www-root 775
+// /home/bdsm/bdsm.sqlite3* must be bdsm:www-root 775
+
 <?php
 $db  = new PDO("sqlite:/home/bdsm/bdsm.sqlite3");
 $result     = $db->query("SELECT * FROM bdsmweb");
@@ -6,7 +9,7 @@ if( $db->errorInfo()[0] == "HY000" )
 {
   $query = "CREATE TABLE bdsmweb (host VARCHAR(128) primary key,".
            "attribute VARCHAR(128), name VARCHAR(128), ".
-           "graph integer, maximum integer, minimim integer, ".
+           "graph integer, maximum integer, minimum integer, ".
            "duration integer);";
   $db->query($query);
 
@@ -18,7 +21,7 @@ if( isset($_POST) )
   foreach( array_keys($_POST) as $key )
   {
     $id = explode("|", $key);
-    $host = $id[0];
+    $host = str_replace("_", ".", $id[0]);
     $attribute = $id[1];
     $setting = $id[2];
     $value = $_POST[$key];
@@ -132,17 +135,19 @@ foreach ($hosts as $host)
     $attributes = Array();
     while($attribute = $result->fetch())
       if ( $attribute['attribute'] )
-        array_push($attributes, $attribute['attribute']);
+        array_push($attributes, $attribute['attribute']);    
     
     foreach($attributes as $attribute)
     {
+      $result = $db->query("SELECT * FROM bdsmweb WHERE host='$host' AND attribute='$attribute'");
+      $values = $result->fetch();
       echo "      <tr>";
       echo "        <td>$attribute</td>";
-      echo "        <td><input type='text' name='$host|$attribute|name' value='' /></td>";
-      echo "        <td><input type='checkbox' name='$host|$attribute|graph' /></td>";
-      echo "        <td><input type='text' name='$host|$attribute|minimum' value='' class='short'/> - ".
-                    "<input type='text' name='$host|$attribute|maximum' value='' class='short'/></td>";
-      echo "        <td><input type='text' name='$host|$attribute|duration' value='' class='short' /></td>";
+      echo "        <td><input type='text' name='$host|$attribute|name' value='".$values['name']."' /></td>";
+      echo "        <td><input type='checkbox' name='$host|$attribute|graph' ".$values['name']?"checked":""."/></td>";
+      echo "        <td><input type='text' name='$host|$attribute|minimum' value='".$values['minimum']."' class='short'/> - ".
+                    "<input type='text' name='$host|$attribute|maximum' value='".$values['maximum']."' class='short'/></td>";
+      echo "        <td><input type='text' name='$host|$attribute|duration' value='".$values['duration']."' class='short' /></td>";
       echo "      </tr>";
     }
     echo "</form>";