diff options
Diffstat (limited to 'htdocs/js.php')
-rw-r--r-- | htdocs/js.php | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/htdocs/js.php b/htdocs/js.php new file mode 100644 index 0000000..c9939fe --- /dev/null +++ b/htdocs/js.php @@ -0,0 +1,31 @@ +<?php + +require __DIR__.'/../init.php'; +global $config; + +$name = $_REQUEST['name'] ?? ''; + +if (!$config['is_dev'] || !$name || !is_dir($path = ROOT.'/htdocs/js/'.$name)) { + http_response_code(403); + exit; +} + +header('Content-Type: application/javascript'); +header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +$files = scandir($path, SCANDIR_SORT_ASCENDING); +$first = true; +foreach ($files as $file) { + if ($file == '.' || $file == '..') + continue; + // logDebug(__FILE__.': reading '.$path.'/'.$file); + if (!$first) + echo "\n"; + else + $first = false; + echo "/* $file */\n"; + if (readfile($path.'/'.$file) === false) + logError(__FILE__.': failed to readfile('.$path.'/'.$file.')'); +} |