first tool supported: xmllint
[phorkie.git] / www / tool.php
diff --git a/www/tool.php b/www/tool.php
new file mode 100644 (file)
index 0000000..d42954c
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+/**
+ * Runs a tool on a file
+ */
+namespace phorkie;
+require_once 'www-header.php';
+$repo = new Repository();
+$repo->loadFromRequest();
+
+if (!isset($_GET['file']) || $_GET['file'] == '') {
+    throw new Exception_Input('File name missing');
+}
+$file = $repo->getFileByName($_GET['file']);
+
+if (!isset($_GET['tool']) || $_GET['tool'] == '') {
+    throw new Exception_Input('Tool name missing');
+}
+
+$tm = new Tool_Manager();
+$tool = $tm->loadTool($_GET['tool']);
+
+$res = $tool->run($file);
+
+render(
+    'tool',
+    array(
+        'repo' => $repo,
+        'file' => $file,
+        'toolres' => $res,
+    )
+);
+
+?>
\ No newline at end of file