From: Christian Weiske Date: Wed, 6 Mar 2019 20:21:21 +0000 (+0100) Subject: Add simple web interface to paste a page URL X-Git-Tag: v1.1.0~1 X-Git-Url: https://git.cweiske.de/playVideoOnDreamboxProxy.git/commitdiff_plain/af9c4898bafbfd823d3b74d225bf6bad701881b8 Add simple web interface to paste a page URL --- diff --git a/www/form.php b/www/form.php new file mode 100644 index 0000000..460864e --- /dev/null +++ b/www/form.php @@ -0,0 +1,49 @@ + + + + + playVideoOnDreamboxProxy + + + + +

playVideoOnDreamboxProxy

+

+ This proxy application allows you to play videos on your Dreambox; + either direct video URLs or videos linked in HTML pages. +

+

+ You may use the + Android app + or the + Firefox browser extension + to control it directly. +

+ + +

Video URL input

+

+ Enter the URL of a video or a web site that contains a video: +

+
+ + +
+

+ Video will be played on + . +

+ + +
+

+ Licensed under the + AGPL v3+. + Homepage. +

+ + diff --git a/www/functions.php b/www/functions.php index b094e36..6ad1044 100644 --- a/www/functions.php +++ b/www/functions.php @@ -7,14 +7,21 @@ function getPageUrl() errorInput('No URL given as command line parameter'); } $pageUrl = $argv[1]; - } else { - if (!isset($_SERVER['CONTENT_TYPE'])) { - errorInput('Content type header missing'); - } else if ($_SERVER['CONTENT_TYPE'] != 'text/plain') { - errorInput('Content type is not text/plain but ' . $_SERVER['CONTENT_TYPE']); - } + } else if (!isset($_SERVER['CONTENT_TYPE'])) { + errorInput('Content type header missing'); + } else if ($_SERVER['CONTENT_TYPE'] == 'text/plain') { + //Android app $pageUrl = file_get_contents('php://input'); + } else if ($_SERVER['CONTENT_TYPE'] == 'application/x-www-form-urlencoded') { + //Web form + if (!isset($_POST['url'])) { + errorInput('"url" POST parameter missing'); + } + $pageUrl = $_POST['url']; + } else { + errorInput('Content type is not text/plain but ' . $_SERVER['CONTENT_TYPE']); } + $parts = parse_url($pageUrl); if ($parts === false) { errorInput('Invalid URL in POST data'); diff --git a/www/play.php b/www/play.php index 8109951..502e3f2 100644 --- a/www/play.php +++ b/www/play.php @@ -8,6 +8,11 @@ if (file_exists($cfgFile)) { include $cfgFile; } +if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'GET') { + require __DIR__ . '/form.php'; + exit(); +} + set_error_handler('errorHandlerStore'); $pageUrl = getPageUrl();