diff --git a/db.php b/db.php
index 47eb900..1de8389 100644
--- a/db.php
+++ b/db.php
@@ -9,14 +9,33 @@ function connect()
}
catch(PDOException $e)
{
- echo '
Error connecting to database.
'; //$e->getMessage();
+ echo 'Error connecting to database.
'; //$e->getMessage();
+ $db = null; //Redundant.
}
return $db;
}
-function addFile($db, $file)
+function addFiles($files)
{
+ $db = connect();
+ if ($db == null) return null;
+
+ foreach ($files as $file)
+ {
+ //echo 'Adding ' . $file['tmp_name'];
+ addFile($file);
+ }
+}
+
+function addFile($file, $db = null)
+{
+ if ($db == null)
+ {
+ $db = connect();
+ if ($db == null) return null;
+ }
+
try
{
//TODO Compress?
@@ -41,6 +60,9 @@ function addFile($db, $file)
function getMSQ($db, $id)
{
+ $db = connect();
+ if ($db == null) return null;
+
try
{
$st = $db->prepare("SELECT msqs.xml FROM msqs INNER JOIN metadata ON metadata.msq = msqs.id WHERE metadata.id = :id");
@@ -56,4 +78,4 @@ function getMSQ($db, $id)
if (!$result) return null;
else return $result['xml'];
}
-?>
\ No newline at end of file
+?>
diff --git a/footer.php b/footer.php
index e03cca2..9ad136d 100644
--- a/footer.php
+++ b/footer.php
@@ -1,5 +1,5 @@