+// /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");
{
$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);
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];
$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>";