// /home/bdsm must be bdsm:www-root 775
// /home/bdsm/bdsm.sqlite3* must be bdsm:www-root 775
-$db = new PDO("sqlite:/home/bdsm/bdsm.sqlite3");
+try
+{
+ $db = new PDO("sqlite:/home/bdsm/etc/bdsm/bdsm.db");
+}
+catch(PDOException $e)
+{
+ echo 'Connection failed: ' . $e->getMessage();
+}
+
$result = $db->query("SELECT * FROM bdsmweb");
if( $db->errorInfo()[0] == "HY000" )
<?php
-$db = new PDO("sqlite:/home/bdsm/bdsm.sqlite3");
+try
+{
+ $db = new PDO("sqlite:/home/bdsm/etc/bdsm/bdsm.db");
+ $result = $db->query("SELECT DISTINCT host FROM MEASUREMENTS");
+}
+catch(PDOException $e)
+{
+ echo 'Connection failed: ' . $e->getMessage();
+}
+
+if( !$result )
+{
+ echo "Error: No data found in database file /home/bdsm/etc/bdsm/bdsm.db";
+ echo "Query: SELECT DISTINCT host FROM MEASUREMENTS";
+}
+
$colors = Array("#55F", "#5F5", "#F55", "#5FF", "#F5F", "#FF5", "#555");
-$result = $db->query("SELECT DISTINCT host FROM MEASUREMENTS;");
$hosts = Array();
while($host = $result->fetch())
if ( $host['host'] )
array_push($hosts, $host['host']);
$host = urldecode($_GET['host']);
-//print_r($hosts);
-//$result = $db->query("SELECT * FROM bdsmweb;");
-//print_r($result->fetch());
-
if( !in_array($host, $hosts) )
die("Error: Host not found.");
?>
context.lineWidth = 2;
<?php
$result = $db->query("SELECT attribute, name FROM bdsmweb WHERE host='$host' AND graph=1;");
+ if( !$result )
+ {
+ echo "Error: No measurements found in database file /home/bdsm/etc/bdsm/bdsm.db for host $host";
+ echo "Query: SELECT attribute, name FROM bdsmweb WHERE host='$host' AND graph=1;";
+ }
+
$attributes = Array();
-
while($attribute = $result->fetch())
-{
+ {
if ( $attribute['attribute'] )
$attributes[$attribute['attribute']] = $attribute['name'];
-}
+ }
$i = 0;
foreach (array_keys($attributes) as $attribute)
{
<div id="charts">
<?php
-$colors = Array("#55F", "#5F5", "#F55", "#5FF", "#F5F", "#FF5", "#555");
+try
+{
+ $db = new PDO("sqlite:/home/bdsm/etc/bdsm/bdsm.db");
+ $result = $db->query("SELECT DISTINCT host FROM MEASUREMENTS");
+}
+catch(PDOException $e)
+{
+ echo 'Connection failed: ' . $e->getMessage();
+}
-$db_handle = new SQLite3("/home/bdsm/bdsm.sqlite3");
-$result = $db_handle->query("SELECT DISTINCT host FROM MEASUREMENTS");
+if( !$result )
+{
+ echo "Error: No data found in database file /home/bdsm/etc/bdsm/bdsm.db";
+ echo "Query: SELECT DISTINCT host FROM MEASUREMENTS";
+}
$hosts = Array();
-while($host = $result->fetchArray(SQLITE3_ASSOC))
+while($host = $result->fetch())
if ( $host['host'] )
array_push($hosts, $host['host']);
foreach ($hosts as $host)
{
$host = urlencode($host);
- echo "<iframe src='graph.php?host=$host' class='graph' scrolling='no' />";
+ echo "<iframe src='graph.php?host=$host' class='graph' scrolling='no'></iframe>";
}
?>