*/ // no files specified return 404 if (empty($_GET['f'])) { header('404 Not found'); echo "SYNTAX: index.php/x.js?f=dir1/file1.js,dir2/file2.js"; exit; } if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { header("HTTP/1.1 304 Not Modified"); exit; } $files = is_array($_GET['f']) ? $_GET['f'] : explode(',', $_GET['f']); header('Cache-Control: must-revalidate'); header('Last-modified: ' . gmdate('r')); header('Content-type: text/javascript'); $time = time()+(365*86400); header('Expires: '.gmdate('r', $time)); foreach($files as $file) { $p = trim(str_replace('/', DIRECTORY_SEPARATOR, $file), DIRECTORY_SEPARATOR); // validate file path if (empty($p) || strpos($p, '..')!==false || strpos($p, '//')!==false || !file_exists($p)) { continue; } // append file contents print file_get_contents($p); flush(); } exit;