-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror.php
More file actions
66 lines (62 loc) · 1.71 KB
/
Copy patherror.php
File metadata and controls
66 lines (62 loc) · 1.71 KB
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
<?php
include "common.php";
include "config.php";
function send_file($file) {
global $ROOTDIR;
$file = urldecode($file);
$nError=0;
if($nError==0) {
$tFilename = $ROOTDIR.$file;
if(!$fdl=@fopen($tFilename,'r')){
die("Invalid file specified: $file");
} else {
$slash = strrpos($file,"/");
$attach_name = substr($file,$slash+1);
header("HTTP/1.1 200 OK");
header("Cache-Control: ");// leave blank to avoid IE errors
header("Pragma: ");// leave blank to avoid IE errors
# send correct headers based on filename
$ext = substr($file,strrpos($file,'.')+1);
switch($ext) {
case("gif"):
header("Content-type: image/gif");
break;
case("mp3"):
case("m4a"):
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"".$attach_name."\"");
header("Content-length:".(string)(filesize($tFilename)));
break;
}
sleep(1);
fpassthru($fdl);
}
} else {
print "Error: $nError; fnum: $fnum; podcast: $podcast; file: $file";
}
}
if(W_ValidateUser()) {
W_SetCurrentUserDetail();
if(!is_blackout_period()) {
$file = getenv("REQUEST_URI");
send_file($file);
} else {
header("HTTP/1.1 403 Forbidden");
?>
<html>
<head>
<title>Blackout period in effect</title>
</head>
<body>
The episode you requested is not available right now because a blackout period is in effect. Please try again later.
</body>
</html>
<?php
}
} else {
header('WWW-Authenticate: Basic realm="podcasts"');
header('HTTP/1.0 401 Unauthorized');
echo 'Access to this podcast is restricted; a password is required.';
exit;
}
?>