fix login
[noxon-gateway.git] / www / index.php
index 2a380377f89e175fcdfccfd73cfea60e9b4d909d..8b803dbd1e84161465d3061f5e0a9b55f1a82b09 100644 (file)
@@ -19,17 +19,12 @@ 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,7 +35,6 @@ 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');
@@ -112,20 +106,23 @@ function sendDir($path)
     foreach ($entries as $entry) {
         $urlPath = pathEncode(substr($entry, strlen($varDir)));
         $ext = pathinfo($entry, PATHINFO_EXTENSION);
+
+        $titleBase = basename($entry);
+        $titleBase = preg_replace('#^[0-9]+_#', '', $titleBase);
         if (is_dir($entry)) {
             ++$count;
-            $listItems[] = getDirItem(basename($entry), $urlPath . '/');
+            $listItems[] = getDirItem($titleBase, $urlPath . '/');
         } else if ($ext == 'url') {
             //podcast
             ++$count;
-            $listItems[] = getPodcastItem(basename($entry, '.url'), $urlPath);
+            $listItems[] = getPodcastItem(basename($titleBase, '.url'), $urlPath);
         } else if (substr($entry, -8) == '.auto.sh') {
             //automatically execute script while listing this directory
             addScriptOutput($listItems, $entry);
         } else if ($ext == 'txt' || $ext == 'sh') {
             //plain text file
             ++$count;
-            $listItems[] = getDirItem(basename($entry, '.' . $ext), $urlPath);
+            $listItems[] = getDirItem(basename($titleBase, '.' . $ext), $urlPath);
         }
     }
     if (!$count) {