<?php
+$db = new PDO("sqlite:/home/bdsm/bdsm.sqlite3");
+$result = $db->query("SELECT * FROM bdsmweb");
+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, ".
+ "duration integer);";
+ $db->query($query);
+
+ $result = $db->query("SELECT * FROM bdsmweb;");
+}
+
+if( isset($_POST) )
+{
+ foreach( array_keys($_POST) as $key )
+ {
+ $id = explode("|", $key);
+ $host = $id[0];
+ $attribute = $id[1];
+ $setting = $id[2];
+ $value = $_POST[$key];
+
+ $query = "INSERT INTO bdsmweb(host, attribute, $setting) ".
+ "VALUES (:host, :attribute, :value);";
+ $stmt = $db->prepare($query);
+
+ if( !$stmt )
+ {
+ print_r($db->errorInfo());
+ }
+
+ $stmt->bindParam(':host', $host);
+ $stmt->bindParam(':attribute', $attribute);
+ $stmt->bindParam(':value', $value);
+
+ $stmt->execute();
+ }
+}
?>
<HTML>
<HEAD>
height: 100%;
width: 15%;
background: linear-gradient(to right, #000 0%,#222 80%,#555 100%);
- padding-top:5em;
+ padding-top:2em;
}
#vmenu a
text-decoration: none;
width: 100%;
text-align: center;
- border-top: 1px solid white;
+ border-bottom: 1px solid white;
padding: .5em .2em;
font-size: larger;
}
{
padding-top: 2em;
}
+
+ #logo
+ {
+ width: 100%;
+ }
</STYLE>
</HEAD>
<BODY>
-<?php print_r($_POST); ?>
<div id="vmenu">
- <a href="https://www.slightlycyberpunk.com/"><img src="bdsm.png" /></a>
+ <a href="https://www.slightlycyberpunk.com/"><img src="bdsm-clear.png" id="logo" /></a>
<a href="index.php">Index</a>
<a href="index.php">Historical</a>
<a href="configure.php">Configuration</a>
- <a></a>
</div>
<table id="options">
<tr>
<th>Graph Duration (seconds)</th>
</tr>
<?php
-$db_handle = new SQLite3("/home/bdsm/bdsm.sqlite3");
-$result = $db_handle->query("SELECT DISTINCT host FROM MEASUREMENTS");
+$result = $db->query("SELECT DISTINCT host FROM MEASUREMENTS");
+print_r($db->errorInfo());
$hosts = Array();
-while($host = $result->fetchArray(SQLITE3_ASSOC))
- if ( $host['host'] )
+while( $host = $result->fetch() )
+ if( $host['host'] != "" )
array_push($hosts, $host['host']);
foreach ($hosts as $host)
echo "<form id='attributes' method='POST' action='configure.php' />";
echo " <tr><th>$host</th>";
echo "<th><input type='submit' value='Update host' /></th></tr>";
- $result = $db_handle->query("SELECT DISTINCT attribute FROM MEASUREMENTS WHERE host='$host'");
+ $result = $db->query("SELECT DISTINCT attribute FROM MEASUREMENTS WHERE host='$host'");
$attributes = Array();
- while($attribute = $result->fetchArray(SQLITE3_ASSOC))
+ while($attribute = $result->fetch())
if ( $attribute['attribute'] )
array_push($attributes, $attribute['attribute']);
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|min' value='' class='short'/> - ".
- "<input type='text' name='$host|$attribute|max' value='' class='short'/></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 " </tr>";
}