X-Git-Url: https://git.cweiske.de/noxon-gateway.git/blobdiff_plain/66b32e4e390df8227c0367c868d33fbf2c9f736a..daeda7055cd10cc88ca0966c8791c1c001e4e30f:/www/index.php diff --git a/www/index.php b/www/index.php index d7d758f..65f6715 100644 --- a/www/index.php +++ b/www/index.php @@ -8,28 +8,25 @@ if (isset($_SERVER['REDIRECT_URL'])) { } $dataDir = __DIR__ . '/../data/'; $varDir = realpath(__DIR__ . '/../var') . '/'; +$cacheDir = __DIR__ . '/../www/cache/'; $host1 = 'http://radio567.vtuner.com/'; $host2 = 'http://radio5672.vtuner.com/'; if ($_SERVER['HTTP_HOST'] !== '') { $host1 = 'http://' . $_SERVER['HTTP_HOST'] . '/'; $host2 = 'http://' . $_SERVER['HTTP_HOST'] . '/'; } +$cacheDirUrl = $host1 . 'cache/'; $cfgFile = $dataDir . 'config.php'; if (file_exists($cfgFile)) { include $cfgFile; } -if (strtolower($fullUri) == '/setupapp/radio567/asp/browsexpa/loginxml.asp?token=0') { - //initial login for "internet radio" and podcasts - //lowercase tags +if (strtolower($fullUri) == '/setupapp/radio567/asp/browsexpa/loginxml.asp?token=0' + || $fullUri == '/RadioNativeLogin.php' +) { + //initial login for "internet radio", podcasts and "my noxon" header('Content-type: text/html'); - readfile($dataDir . 'initial-login.xml'); - exit(); -} else if ($fullUri == '/RadioNativeLogin.php') { - //initial login for "My noxon" - //this one wants CamelCased tags - header('Content-type: text/html'); - readfile($dataDir . 'login-mynoxon.xml'); + readfile($dataDir . 'login-camelcase.xml'); exit(); } else if ($path == '/setupapp/radio567/asp/BrowseXPA/LoginXML.asp') { //"Internet Radio" @@ -40,20 +37,15 @@ if (strtolower($fullUri) == '/setupapp/radio567/asp/browsexpa/loginxml.asp?token } else if ($path == '/RadioNative.php') { //"My Noxon" $path = '/mynoxon/'; - $path = '/internetradio/'; } else if ($path == '/setupapp/radio567/asp/BrowseXML/FavXML.asp') { //Internet Radio Station favorites favorited on device sendMessage('Unsupported'); } else if ($path == '/RadioNativeFavorites.php') { //Favorites, defined via web interface sendMessage('Unsupported'); -} else if (substr($path, 0, 9) == '/play-url') { - //play a given URL, but first follow all redirects - //noxon iRadio Cube does not like too many redirections - // 3 redirects did not work. - $url = $_GET['url']; - header('HTTP/1.0 301 Moved Permanently'); - header('Location: ' . getFinalUrl($url)); +} else if ($path == '/transcode') { + require_once 'mediatomb.php'; + transcodeMediatombItem($_GET['mtParentId'], $_GET['mtItemTitle']); exit(); } @@ -207,7 +199,7 @@ function getEpisodeItem($title, $fullUrl, $desc, $type) return '' . 'ShowEpisode' . '' . utf8_decode(htmlspecialchars($title)) . '' - . '' . $fullUrl . '' + . '' . htmlspecialchars($fullUrl) . '' . '' . utf8_decode(htmlspecialchars($desc)) . '' . '' . $type . '' . ''; @@ -250,19 +242,6 @@ function addPreviousItem(&$listItems, $urlPath) $listItems[] = getPreviousItem($parentDir); } -function getFinalUrl($url) -{ - $ctx = stream_context_set_default( - array('http' => array('method' => 'HEAD')) - ); - //get_headers follows redirects automatically - $headers = get_headers($url, 1); - if ($headers !== false && isset($headers['Location'])) { - return end($headers['Location']); - } - return $url; -} - function sendMessage($msg) { sendListItems(array(getMessageItem($msg)));