r180: The OR should be an AND in the permission checking expression
[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 require_once('./global.php');
16
17 $attachment = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "attachment WHERE attachmentid = " . intval($bugsys->in['attachmentid']));
18 if (!$attachment)
19 {
20 $message->error('alert: bad attachment');
21 }
22
23 if (!can_perform('cangetattach') AND !can_perform('caneditattach'))
24 {
25 $message->error_permission();
26 }
27
28 ob_clean();
29 ob_end_clean();
30
31 if ($funct->fetch_extension($attachment['filename']) != 'txt')
32 {
33 header("Content-Disposition: inline; filename=$attachment[filename]");
34 header("Content-transfer-encoding: binary");
35 }
36 else
37 {
38 header("Content-Disposition: attachment; filename=$attachment[filename]");
39 }
40 header("Content-Length: " . strlen($attachment['attachment']));
41 header("Content-Type: $attachment[mimetype]");
42
43 print($attachment['attachment']);
44
45 /*=====================================================================*\
46 || ###################################################################
47 || # $HeadURL$
48 || # $Id$
49 || ###################################################################
50 \*=====================================================================*/
51 ?>