aboutsummaryrefslogtreecommitdiff
path: root/www/raw.php
blob: 605462da41d267184cb522219917ca21a51caccb (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
<?php
namespace phorkie;
/**
 * Displays a file
 */
$reqWritePermissions = false;
require_once 'www-header.php';

$repo = new Repository();
$repo->loadFromRequest();

if (!isset($_GET['file']) || $_GET['file'] == '') {
    throw new Exception_Input('File name missing');
}

$file = $repo->getFileByName($_GET['file']);
$mimetype = $file->getMimeType();
if ($mimetype === null) {
    $mimetype = 'text/plain';
}
header('Content-Type: ' . $mimetype);
if ($repo->hash === null) {
    //IIRC readfile is not so memory-intensive for big files
    readfile($file->getFullPath());
} else {
    echo $file->getContent();
}
?>