blob: 40ee579eaec7ee4b3f36794bcf0b92e3730ec4b8 (
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
|
<?php
function init_passthrough(&$S) {
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(&$S) {
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']);
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';
}
}
?>
|