Merge remote-tracking branch 'origin/QA_4_0' into QA_4_0
[phpmyadmin.git] / js / get_scripts.js.php
blob564fda7dd2b438ff235c2965c88031867d0eb9bb
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Concatenates reveral js files to reduce the number of
5 * http requests sent to the server
7 * @package PhpMyAdmin
8 */
9 chdir('..');
11 // Send correct type
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) {
18 // Sanitise filename
19 $script_name = 'js';
20 $path = explode("/", $script);
21 foreach ($path as $index => $filename) {
22 if (! preg_match("@^\.+$@", $filename)
23 && preg_match("@^[\w\.-]+$@", $filename)
24 ) {
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);
33 echo ";\n\n";