';
+ include "view/footer.php";
+ }
} else {
include "index.php";
}
diff --git a/src/msq.php b/src/msq.php
index 3b2b97d..89d465b 100644
--- a/src/msq.php
+++ b/src/msq.php
@@ -27,7 +27,7 @@ class MSQ
/**
* @brief Format a constant to HTML
* @param $constant The constant name
- * @param $value It's value
+ * @param $value Its value
* @returns String HTML \
';
foreach ($constants as $key => $config)
{
if ($config[0] == "array") continue; //TODO Skip arrays until blacklist is done
@@ -180,9 +187,12 @@ public function parseMSQ($xml, &$engine, &$metadata)
if (array_key_exists($key, $helpTexts))
$help = $helpTexts[$key];
- $html["constants"] .= $this->msqConstant($key, $value, $help);
+ $html["tabList"] .= $this->msqConstant($key, $value, $help);
}
}
+ $html["tabList"] .= '
';
+ $html["tabList"] .= '
';
+
}
return $html;
diff --git a/src/msqur.php b/src/msqur.php
index 2d2c8fb..7632678 100644
--- a/src/msqur.php
+++ b/src/msqur.php
@@ -45,8 +45,7 @@ public function getCachedMSQ($id)
public function getMSQForDownload($id)
{
-
- return $this->db->getMSQForDownload($id);
+ return $this->db->getXML($id);
}
public function addMSQs($files, $engineid)
@@ -141,16 +140,15 @@ public function getEngineCodeList($make = null)
*/
public function view($id)
{
- $this->header();
if (DEBUG) debug('Load MSQ: ' . $id);
//Get cached HTML and display it, or reparse and display (in order)
$html = $this->getCachedMSQ($id);
- if ($html !== null)
+ if ($html !== FALSE)
{
$this->db->updateViews($id);
$msq = new MSQ(); //ugh
- if ($html == FALSE)
+ if ($html == null)
{
$engine = array();
$metadata = array();
@@ -165,22 +163,22 @@ public function view($id)
foreach($groupedHtml as $group => $v)
{
//TODO Group name as fieldset legend or sth
- $html .= "
";
+ //$html .= "
";
$html .= $v;
- $html .= '
';
+ //$html .= '
';
}
$this->db->updateCache($id, $html);
} catch (MSQ_ParseException $e) {
$html = $e->getHTMLMessage();
- }
+ } finally {
+ return $html;
+ }
}
}
}
- //TODO else show 404
-
- echo $html;
- $this->footer();
+
+ return null;
}
public function addEngine($make, $code, $displacement, $compression, $turbo)
diff --git a/src/upload.php b/src/upload.php
index 0eb3f24..e79758d 100644
--- a/src/upload.php
+++ b/src/upload.php
@@ -68,7 +68,7 @@ function checkUploads($files)
//Get and check mime types (ignoring provided ones)
$finfo = new finfo(FILEINFO_MIME_TYPE);
$mimeType = $finfo->file($file['tmp_name']);
- if ($mimeType != "application/xml" && $mimeType != "text/xml")
+ if (!acceptableMimeType($mimeType))
{
if (DEBUG) warn('File: ' . $file['tmp_name'] . ': Invalid MIME type ' . $mimeType);
unset($files[$index]);
@@ -79,6 +79,22 @@ function checkUploads($files)
return $files;
}
+/**
+ * @brief Check that a mime type matches ones we think are OK.
+ * @param $mimeType {string} MIME type
+ * @returns true or false
+ */
+function acceptableMimeType($mimeType) {
+ switch ($mimeType) {
+ case "application/xml":
+ case "text/xml":
+ case "text/plain":
+ return true;
+ default:
+ return FALSE;
+ }
+}
+
//var_export($_POST);
//var_export($_FILES);
diff --git a/src/view.php b/src/view.php
index 58561a9..997c275 100644
--- a/src/view.php
+++ b/src/view.php
@@ -18,7 +18,20 @@
require "msqur.php";
if (isset($_GET['msq'])) {
- echo $msqur->view($_GET['msq']);
+ $id = $_GET['msq']; //TODO Sanitize
+ $html = $msqur->view($_GET['msq']);
+ if ($html !== null) {
+ include "view/header.php";
+ echo $html;
+ include "view/footer.php";
+ } else {
+ http_response_code(404);
+ unset($_GET['msq']);
+ include "view/header.php";
+ echo '