aboutsummaryrefslogtreecommitdiff
path: root/www/embed-file.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/embed-file.php')
-rw-r--r--www/embed-file.php27
1 files changed, 27 insertions, 0 deletions
diff --git a/www/embed-file.php b/www/embed-file.php
new file mode 100644
index 0000000..0ece1b9
--- /dev/null
+++ b/www/embed-file.php
@@ -0,0 +1,27 @@
+<?php
+namespace phorkie;
+/**
+ * Embed a file of a paste into a HTML site.
+ * We deliver javascript for that.
+ */
+$reqWritePermissions = false;
+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']);
+header('Content-Type: text/javascript');
+header('Expires: ' . date('r', time() + 3600));
+render(
+ 'embed-file',
+ array(
+ 'repo' => $repo,
+ 'file' => $file,
+ )
+);
+?>