aboutsummaryrefslogtreecommitdiff
path: root/tv/watch.php
diff options
context:
space:
mode:
Diffstat (limited to 'tv/watch.php')
-rw-r--r--tv/watch.php27
1 files changed, 27 insertions, 0 deletions
diff --git a/tv/watch.php b/tv/watch.php
new file mode 100644
index 0000000..def8da7
--- /dev/null
+++ b/tv/watch.php
@@ -0,0 +1,27 @@
+<?php
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php";
+
+if (!isset($_GET['i'])) {
+ die();
+}
+
+if (strpos($_GET['i'], ".") !== false || strpos($_GET['i'], "/") !== false) {
+ die();
+}
+
+$film = $_GET['i'];
+$id = bin2hex(random_bytes(96));
+
+if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/films/video/" . $film . '@4K.mp4')) {
+ $source4k = $_SERVER['DOCUMENT_ROOT'] . "/data/films/video/" . $film . '@4K.mp4';
+ $dest4k = $_SERVER['DOCUMENT_ROOT'] . "/cdn/video/" . $id . ".mp4";
+ symlink($source4k, $dest4k);
+} else {
+ $source = $_SERVER['DOCUMENT_ROOT'] . "/data/films/video/" . $film . '.mp4';
+ $dest = $_SERVER['DOCUMENT_ROOT'] . "/cdn/video/" . $id . ".mp4";
+ symlink($source, $dest);
+}
+
+header("Location: /cdn/video/" . $id . ".mp4");
+exit; \ No newline at end of file