summaryrefslogtreecommitdiff
path: root/htdocs/js.php
blob: 57d847f477d6e21634b2d7241b9cd012fe68dd4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php

require __DIR__.'/../init.php';

$name = $_REQUEST['name'] ?? '';

if (!is_dev() || !$name || !is_dir($path = APP_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.')');
}