2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Concatenates reveral js files to reduce the number of
5 * http requests sent to the server
12 header('Content-Type: text/javascript; charset=UTF-8');
13 // Enable browser cache for 1 hour
14 header('Expires: ' . gmdate('D, d M Y H:i:s', time() +
3600) . ' GMT');
16 if (! empty($_GET['scripts']) && is_array($_GET['scripts'])) {
17 foreach ($_GET['scripts'] as $script) {
20 $path = explode("/", $script);
21 foreach ($path as $index => $filename) {
22 if (! preg_match("@^\.+$@", $filename)
23 && preg_match("@^[\w\.-]+$@", $filename)
25 // Disallow "." and ".." alone
26 // Allow alphanumeric, "." and "-" chars only
27 $script_name .= DIRECTORY_SEPARATOR
. $filename;
30 // Output file contents
31 if (preg_match("@\.js$@", $script_name) && is_readable($script_name)) {
32 readfile($script_name);