2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Concatenates several js files to reduce the number of
5 * http requests sent to the server
12 // Close session early as we won't write anything there
13 session_write_close();
16 header('Content-Type: text/javascript; charset=UTF-8');
17 // Enable browser cache for 1 hour
18 header('Expires: ' . gmdate('D, d M Y H:i:s', time() +
3600) . ' GMT');
20 if (! empty($_GET['scripts']) && is_array($_GET['scripts'])) {
21 foreach ($_GET['scripts'] as $script) {
25 $path = explode("/", $script);
26 foreach ($path as $index => $filename) {
27 // Allow alphanumeric, "." and "-" chars only, no files starting
29 if (preg_match("@^[\w][\w\.-]+$@", $filename)) {
30 $script_name .= DIRECTORY_SEPARATOR
. $filename;
34 // Output file contents
35 if (preg_match("@\.js$@", $script_name) && is_readable($script_name)) {
36 readfile($script_name);
42 if (isset($_GET['call_done'])) {
43 echo "AJAX.scriptHandler.done();";