|
Revision 2, 1.3 kB
(checked in by sven, 3 years ago)
|
importing elgg-0.1.1a
|
| Line | |
|---|
| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
// Usage: http://URL/{username}/files/{folder_id}/{file_id}/{filename} |
|---|
| 5 |
|
|---|
| 6 |
// Run includes |
|---|
| 7 |
require("../includes.php"); |
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
run("userdetails:init"); |
|---|
| 11 |
run("profile:init"); |
|---|
| 12 |
run("files:init"); |
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
if (isset($_REQUEST['id'])) { |
|---|
| 17 |
$id = (int) $_REQUEST['id']; |
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
$file = db_query("select * from files where ident = $id"); |
|---|
| 22 |
if (sizeof($file) > 0) { |
|---|
| 23 |
|
|---|
| 24 |
$file = $file[0]; |
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
if (run("users:name_to_id",$_REQUEST['files_name']) == $file->owner) { |
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
if (run("users:access_level_check",$file->access) == true) { |
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
$mimetype = run("files:mimetype:inline",$file->location); |
|---|
| 37 |
if ($mimetype == false) { |
|---|
| 38 |
$mimetype = "application/data"; |
|---|
| 39 |
} |
|---|
| 40 |
|
|---|
| 41 |
header("Content-type: $mimetype"); |
|---|
| 42 |
if ($mimetype == "application/data") { |
|---|
| 43 |
header('Content-Disposition: attachment'); |
|---|
| 44 |
} |
|---|
| 45 |
readfile($file->location); |
|---|
| 46 |
|
|---|
| 47 |
} |
|---|
| 48 |
|
|---|
| 49 |
} |
|---|
| 50 |
} |
|---|
| 51 |
} |
|---|
| 52 |
|
|---|
| 53 |
?> |
|---|