Use file executable bit for script detection.
[noxon-gateway.git] / www / index.php
index d9b53f1e5677acdc6d20e089f3c2ba775dc4dbe2..1670931256fb90df76956f3b46b181dae5b9503c 100644 (file)
@@ -60,7 +60,7 @@ function handleRequest($path)
         sendPodcast($path);
     } else if ($ext == 'txt') {
         sendTextFile($path);
-    } else if ($ext == 'sh') {
+    } else if (is_executable($fullPath)) {
         sendScript($path);
     } else {
         sendMessage('Unknown file type');
@@ -94,10 +94,12 @@ function sendDir($path)
             //podcast
             ++$count;
             $listItems[] = getPodcastItem(basename($titleBase, '.url'), $urlPath);
-        } else if (substr($entry, -8) == '.auto.sh') {
+        } else if (is_executable($entry)
+            && strpos(basename($entry), '.auto') !== false
+        ) {
             //automatically execute script while listing this directory
             addScriptOutput($listItems, $entry);
-        } else if ($ext == 'txt' || $ext == 'sh') {
+        } else if ($ext == 'txt' || is_executable($entry)) {
             //plain text file
             ++$count;
             $listItems[] = getDirItem(basename($titleBase, '.' . $ext), $urlPath);