Skip to content

Instantly share code, notes, and snippets.

@ktmud
Created August 9, 2013 08:01
Show Gist options
  • Save ktmud/6191907 to your computer and use it in GitHub Desktop.
Save ktmud/6191907 to your computer and use it in GitHub Desktop.
<?
/*by qiuchi @ 2010-11-03 */
$uri = str_replace('index.php', '', $_SERVER["REQUEST_URI"]);
//echo $uri . "\n\n";
if ( !strpos($uri, '??') ) {
include_once 'fetch.php';
exit;
}
$filedir = substr($uri, 0, strpos($uri, '??'));
// echo $filedir."\n\n";
$uri = str_replace($filedir.'??', '', $uri);
$filelist = preg_replace('/\?t=.*/s', '', $uri);
$files = explode(',', $filelist);
header('HTTP/1.0 200 OK');
if (strpos('css', $uri) !== -1) {
header('Content-type: text/css');
} else {
header('Content-type: text/javascript');
}
echo '/* combo of '.$filelist." */";
foreach ($files as $file) {
$file = $filedir.$file;
echo "\n\n/*----- ". $file ." ----*/\n";
$localfile = $_SERVER['DOCUMENT_ROOT'].$file;
$file = 'http://localhost'.$file;
if (file_exists($localfile)) {
$file = $localfile;
}
if ($fp = @fopen($file, "r")){
$contents = stream_get_contents($fp);
echo $contents;
fclose($fp);
} else {
echo '';
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment