r527: Base new permission checks
[bugdar.git] / viewattachment.php
1 <?php
2 /*=====================================================================*\
3 || ################################################################### ||
4 || # BugStrike [#]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 // #*# permission checks per-bug and hidden bugs
28
29 if (!can_perform('cangetattach') AND !can_perform('caneditattach'))
30 {
31 $message->error_permission();
32 }
33
34 ob_clean();
35 ob_end_clean();
36
37 if ($funct->fetch_extension($attachment['filename']) != 'txt')
38 {
39 header("Content-Disposition: inline; filename=$attachment[filename]");
40 header("Content-transfer-encoding: binary");
41 }
42 else
43 {
44 header("Content-Disposition: attachment; filename=$attachment[filename]");
45 }
46 header("Content-Length: " . strlen($attachment['attachment']));
47 header("Content-Type: $attachment[mimetype]");
48
49 print($attachment['attachment']);
50
51 /*=====================================================================*\
52 || ###################################################################
53 || # $HeadURL$
54 || # $Id$
55 || ###################################################################
56 \*=====================================================================*/
57 ?>