aboutsummaryrefslogtreecommitdiff
path: root/app/controllers/media_proxy.php
diff options
context:
space:
mode:
authorJan-Hendrik Willms <tleilax+github@gmail.com>2021-07-22 16:07:19 +0200
committerJan-Hendrik Willms <tleilax+github@gmail.com>2021-07-22 16:19:12 +0200
commita3da1483a9e689846179159355badfec8073dbec (patch)
tree770dcca6bdf5f6f2a11b0e7fcbbeda6919a3fc52 /app/controllers/media_proxy.php
current code from svn, revision 62608
Diffstat (limited to 'app/controllers/media_proxy.php')
-rw-r--r--app/controllers/media_proxy.php60
1 files changed, 60 insertions, 0 deletions
diff --git a/app/controllers/media_proxy.php b/app/controllers/media_proxy.php
new file mode 100644
index 0000000..50dc3df
--- /dev/null
+++ b/app/controllers/media_proxy.php
@@ -0,0 +1,60 @@
+<?php
+/**
+ * media_proxy.php - media proxy controller
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * @author Elmar Ludwig
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
+ * @category Stud.IP
+ */
+
+class MediaProxyController extends StudipController
+{
+ /**
+ * Empty before filter to avoid any unwanted output changes.
+ *
+ * @param string $action
+ * @param array $args
+ */
+ public function before_filter(&$action, &$args)
+ {
+ }
+
+ /**
+ * default action of this controller: proxy media data
+ */
+ public function index_action()
+ {
+ $url = Request::get('url');
+ $media_proxy = new MediaProxy();
+ $config = Config::GetInstance();
+ $modified_since = NULL;
+
+ if (!Seminar_Session::is_current_session_authenticated() ||
+ $config->getValue('LOAD_EXTERNAL_MEDIA') != 'proxy') {
+ throw new AccessDeniedException();
+ }
+
+ if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
+ $modified_since = strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']);
+ }
+
+ ini_set('default_socket_timeout', 5);
+ $this->render_nothing();
+
+ //stop output buffering started in Trails_Dispatcher::dispatch()
+ while (ob_get_level()) {
+ ob_end_clean();
+ }
+
+ try {
+ $media_proxy->readURL($url, $modified_since);
+ } catch (MediaProxyException $ex) {
+ header($ex->getMessage());
+ }
+ }
+}