default: // unidentified type: no optimization support. break; } // Store cache if ($cache) { if ($fp = @fopen($cachedir . '/' . $cachefile, 'wb')) { fwrite($fp, $contents); fclose($fp); } else { send_response_status_header(500); die("Failed to write data to cache file: " . $cachedir . '/' . $cachefile); } } if ($cfg['COMBINER_DEV_DUMP_OUTPUT'] && $cfg['IN_DEVELOPMENT_ENVIRONMENT']) { $dump_filename = str2VarOrFileName($_GET['files']) . '.' . ($type == 'javascript' ? 'js' : $type); if ($fp = @fopen($cachedir . '/' . $dump_filename, 'wb')) { fwrite($fp, $contents); fclose($fp); } else { send_response_status_header(500); die("Failed to write data to development diagnostics dump file: " . $cachedir . '/' . $dump_filename); } } // Send Content-Type header("Content-Type: text/" . $type . '; charset=UTF-8'); if (isset($encoding) && $encoding != 'none') { // Send compressed contents $contents = gzencode($contents, 9, $gzip ? FORCE_GZIP : FORCE_DEFLATE); header("Content-Encoding: " . $encoding); header('Content-Length: ' . strlen($contents));
/** * As filterParam4IdOrNumber(), but also accepts '_' underscores and '.' dots, but NOT at the start or end of the filename! */ function filterParam4Filename($value, $def = null, $try_to_keep_unique = false) { if (!isset($value)) { return $def; } $value = str2VarOrFileName($value, '~\\.', false, MAX_REASONABLE_FILENAME_LENGTH, $try_to_keep_unique); return $value; }