Move to git-archive for zip support
[gitphp.git] / include / display.git_blob_plain.php
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
<?php
/*
 *  display.git_blob_plain.php
 *  gitphp: A PHP git repository browser
 *  Component: Display - blob (plaintext)
 *
 *  Copyright (C) 2008 Christopher Han <xiphux@gmail.com>
 */
 
 require_once('gitutil.git_cat_file.php');
 require_once('util.file_mime.php');
 
function git_blob_plain($projectroot,$project,$hash,$file)
{
        global $gitphp_conf;
 
        if ($file)
                $saveas = $file;
        else
                $saveas = $hash . ".txt";
 
        $buffer = git_cat_file($projectroot . $project, $hash);
 
        if ($gitphp_conf['filemimetype'])
                $mime = file_mime($buffer, $file);
 
        if ($mime)
                header("Content-type: " . $mime);
        else
                header("Content-type: text/plain; charset=UTF-8");
 
        header("Content-disposition: inline; filename=\"" . $saveas . "\"");
 
        echo $buffer;
}
 
?>
 
comments