Fixing config saving
authorBrian Flowers <git-admn@bsflowers.net>
Tue, 27 Sep 2016 06:55:16 +0000 (02:55 -0400)
committerBrian Flowers <git-admn@bsflowers.net>
Tue, 27 Sep 2016 06:55:16 +0000 (02:55 -0400)
configure.php

index 4742186..0b9e66b 100755 (executable)
@@ -27,30 +27,28 @@ if( isset($_POST) )
     $value = $_POST[$key];
     if($value == "on")
       $value = 1;
+    if($value == "off")
+      $value = 0;
 
     if( $attribute != "" )
     {
       $params = array(':host' => $host, 
-                    ':attribute' => $attribute, 
-                    ':setting' => $setting, 
-                    ':value' => $value);
-        
+                    ':attribute' => $attribute);
+
       $insert = "INSERT INTO bdsmweb(host, attribute) ".
               "VALUES (:host, :attribute);";
       $stmt = $db->prepare($insert);
+      $stmt->execute($params);
 
-      if( $stmt )
-        $stmt->execute($params);
-      
-      $update = "UPDATE bdsmweb SET :setting=:value ".
+      $params[':value'] = $value;
+      $update = "UPDATE bdsmweb SET $setting=:value ".
               "WHERE host=:host AND attribute=:attribute;";
       $stmt = $db->prepare($update);
-      
-      if( $stmt )
-        $stmt->execute($params);
+      $stmt->execute($params);
     }
   }
 }
+
 ?>
 <HTML>
   <HEAD>
@@ -152,7 +150,7 @@ foreach ($hosts as $host)
       echo "      <tr>";
       echo "        <td>$attribute</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='checkbox' name='$host|$attribute|graph' ".($values['graph']?"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>";