Translated using Weblate (Bulgarian)
[phpmyadmin.git] / js / get_scripts.js.php
blobfdeddf4c3bb6f2e9f1da4c4198e8619bda69ef3c
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Concatenates several js files to reduce the number of
5 * http requests sent to the server
7 * @package PhpMyAdmin
8 */
10 chdir('..');
12 // Close session early as we won't write anything there
13 session_write_close();
15 // Send correct type
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) {
22 // Sanitise filename
23 $script_name = 'js';
25 $path = explode("/", $script);
26 foreach ($path as $index => $filename) {
27 // Allow alphanumeric, "." and "-" chars only, no files starting
28 // with .
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);
37 echo ";\n\n";
42 if (isset($_GET['call_done'])) {
43 echo "AJAX.scriptHandler.done();";