r860: Renaming the branch to be the right name
[bugdar.git] / viewattachment.php
1 <?php
2 /*=====================================================================*\
3 || ################################################################### ||
4 || # Bugdar [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # Copyright ©2002-[#]year[#] by Iris Studios, Inc. All Rights Reserved. # ||
7 || # This file may not be reproduced in any way without permission. # ||
8 || # --------------------------------------------------------------- # ||
9 || # User License Agreement at http://www.iris-studios.com/license/ # ||
10 || ################################################################### ||
11 \*=====================================================================*/
12
13 ob_start();
14
15 define('SVN', '$Id$');
16
17 $focus['showreport'] = 'focus';
18
19 require_once('./global.php');
20
21 $attachment = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "attachment WHERE attachmentid = " . intval($bugsys->in['attachmentid']));
22 if (!$attachment)
23 {
24 $message->error($lang->getlex('error_invalid_id'));
25 }
26
27 $bug = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = $attachment[bugid]");
28 if (($bug['hidden'] AND !can_perform('canviewhidden', $bug['productid'])) OR !can_perform('canviewbugs', $bug['productid']))
29 {
30 $message->error_permission();
31 }
32
33 if (!can_perform('cangetattach', $bug['productid']))
34 {
35 $message->error_permission();
36 }
37
38 ob_clean();
39 ob_end_clean();
40
41 if ($funct->fetch_extension($attachment['filename']) != 'txt')
42 {
43 header("Content-Disposition: inline; filename=$attachment[filename]");
44 header("Content-transfer-encoding: binary");
45 }
46 else
47 {
48 header("Content-Disposition: attachment; filename=$attachment[filename]");
49 }
50 header("Content-Length: " . strlen($attachment['attachment']));
51 header("Content-Type: $attachment[mimetype]");
52
53 print($attachment['attachment']);
54
55 /*=====================================================================*\
56 || ###################################################################
57 || # $HeadURL$
58 || # $Id$
59 || ###################################################################
60 \*=====================================================================*/
61 ?>