blob: e444aa21cdfadd04e1047292e7d236ee7e69e486 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
<?php
function init_passthrough() {
global $S, $request;
if (strpos('../',$request['dir'].'/'.$request['file']) !== false || !file_exists($request['dir'].'/'.$request['file']) && !file_exists($request['dir'].'/'.$request['file'].'.php')) {
debug('passthrough','File not found '.$request['dir'].'/'.$request['file']);
return '404';
}
switch (strtolower($request['ext'])) {
// http://www.w3schools.com/media/media_mimeref.asp
case 'mp3':
contenttype('audio/mpeg');
break;
case 'jpg':
case 'jpeg':
contenttype('image/jpeg');
break;
case 'gif':
contenttype('image/gif');
break;
case 'ico':
contenttype('image/x-icon');
break;
case 'png':
contenttype('image/png');
break;
case 'js':
contenttype('application/x-javascript');
break;
case 'css':
contenttype('text/css');
break;
case 'html':
case 'htm':
case 'xhtml':
contenttype('text/html');
break;
case 'php':
$S['notemplates']=true;
break;
case 'gz':
case 'gzip':
contenttype('application/x-gzip');
break;
case 'tbz2':
case 'bz2':
contenttype('application/bzip2');
break;
default:
debug('passthrough', 'Unknown extension '.$request['ext']);
return '404';
}
// Set filesize if we're working with a static file (needed for normal download and streaming behavior)
if (strtolower($request['ext']) != 'php' && file_exists($request['dir'].'/'.$request['file'])) {
header('Content-Length: '.filesize($request['dir'].'/'.$request['file']));
}
// Force browser to download, possibly set dynamic filename, passed by previous page or by HTTP request (taken from the PHP manual on readfile()
if (isset($request['download']) && $request['download']) {
header('Content-Description: File Transfer');
header('Content-Transfer-Encoding: binary');
if (isset($request['download_name']) && strlen($request['download_name']) > 0) {
header('Content-Disposition: attachment; filename="'.str_replace('"','\'', $request['download_name']).'"');
} else {
header('Content-Disposition: attachment');
}
}
$S['notemplates']=true;
}
function body_passthrough() {
global $request;
if (strtolower($request['ext']) == 'php') {
$_SERVER['PHP_SELF']=substr($_SERVER['PHP_SELF'],0,strlen($_SERVER['PHP_SELF'])-strlen('main.php')).$request['dir'].'/'.$request['file'];
unset($GLOBALS['S'], $GLOBALS['request'], $GLOBALS['conf']);
chdir($request['dir']);
error_reporting(E_DEFAULT);
return $request['file'];
} elseif (file_exists($request['dir'].'/'.$request['file'])) {
readfile($request['dir'].'/'.$request['file']);
} else {
return $request['dir'].'/'.$request['file'].'.php';
}
}
?>
|