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 \*=====================================================================*/
13 $fetchtemplates = array(
18 require_once('./global.php');
20 if (isset($bugsys->in
['attachmentid']))
22 $attachment = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "attachment WHERE attachmentid = " . intval($bugsys->in
['attachmentid']));
25 echo 'alert: bad attachment';
30 $bug = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid = " . (($attachment['attachmentid']) ?
$attachment['bugid'] : intval($bugsys->in
['bugid'])));
33 echo 'alert: bad bug';
37 // ###################################################################
39 if ($_REQUEST['do'] == 'kill')
41 // run code to remove item in database
44 // ###################################################################
46 if ($_REQUEST['do'] == 'delete')
48 // display delete confirmation message
51 // ###################################################################
53 if ($_POST['do'] == 'insert')
55 if (!can_perform('canputattach'))
57 echo 'alert: no permission';
62 $FILE =& $_FILES['attachment'];
65 switch ($FILE['error'])
68 case 1: echo 'PHP said the file you uploaded was too big.'; exit; break;
69 case 2: echo 'The file exceeds the allowed upload size.'; exit; break;
70 case 3: echo 'The file was only partially uploaded.'; exit; break;
71 case 4: echo 'The file was not uploaded at all.'; exit; break;
72 case 6: echo 'PHP could not find the /tmp directory.'; exit; break;
76 if (!is_uploaded_file($FILE['tmp_name']))
78 echo 'The file you specified did not upload.';
82 // #*# put some MIME-type validation here
84 if (!$bugsys->in
['description'])
86 echo 'you need a file description!';
90 $filedata = $bugsys->escape(file_get_contents($FILE['tmp_name']), true
, true
);
93 // insert an attachment
95 INSERT INTO attachment
96 (bugid, filename, mimetype, filesize,
97 attachment, description, dateline, userid)
99 ($bug[bugid], '" . $bugsys->escape($FILE['name']) . "',
100 '" . $bugsys->escape($FILE['type']) . "', " . intval($FILE['size']) . ",
101 '$filedata', '" . $bugsys->in
['description'] . "', $time,
102 " . $bugsys->userinfo
['userid'] . "
107 $obsoletes = $_POST['obsoletes'];
108 array_walk($obsoletes, 'intval');
109 $db->query("UPDATE " . TABLE_PREFIX
. "attachment SET obsolete = 1 WHERE attachmentid IN (" . implode(',', $obsoletes) . ") AND !obsolete AND bugid = $bug[bugid]");
111 // handle comment stuff
112 if (can_perform('canpostcomments') AND trim($bugsys->in
['comment']))
114 $bugsys->in
['comment_parsed'] = $bugsys->in
['comment'];
116 if (!$bugsys->options
['allowhtml'])
118 $bugsys->in
['comment_parsed'] = $bugsys->sanitize($bugsys->in
['comment_parsed']);
122 INSERT INTO " . TABLE_PREFIX
. "comment
123 (bugid, userid, dateline, comment, comment_parsed)
125 ($bug[bugid], " . $bugsys->userinfo
['userid'] . ",
126 $time, '" . $bugsys->in
['comment'] . "',
127 '" . nl2br($bugsys->in
['comment_parsed']) . "'
132 // update the last post data
133 $db->query("UPDATE " . TABLE_PREFIX
. "bug SET lastposttime = $time, lastpostby = " . $bugsys->userinfo
['userid'] . " WHERE bugid = $bug[bugid]");
135 echo "<a href=\"showreport.php?bugid=$bug[bugid]\">attachment added</a>";
139 // ###################################################################
141 if ($_REQUEST['do'] == 'add')
143 if (!can_perform('canputattach'))
145 echo 'alert: no permission';
149 $MAXFILESIZE = $funct->fetch_max_attachment_size();
151 $show['addcomment'] = ((can_perform('canpostcomments')) ? true
: false
);
152 $show['obsoletes'] = false
;
154 $obsoletes_fetch = $db->query("SELECT * FROM " . TABLE_PREFIX
. "attachment WHERE bugid = $bug[bugid] AND !obsolete");
156 while ($obsolete = $db->fetch_array($obsoletes_fetch))
158 $show['obsoletes'] = true
;
159 $obsoletes .= "<div><input name=\"obsoletes[]\" type=\"checkbox\" value=\"$obsolete[attachmentid]\" /> $obsolete[filename] [$obsolete[description]]</div>\n";
162 eval('$template->flush("' . $template->fetch('newattach') . '");');
165 // ###################################################################
167 if ($_POST['do'] == 'update')
169 if (!(can_perform('caneditattach') OR ($attachment['userid'] == $bugsys->userinfo
['userid'] AND can_perform('canputattach'))))
171 echo 'alert: no permssion';
176 UPDATE " . TABLE_PREFIX
. "attachment
177 SET description = '" . $bugsys->in
['description'] . "',
178 obsolete = " . intval($bugsys->in
['obsolete']) . "
179 WHERE attachmentid = " . intval($bugsys->in
['attachmentid'])
182 echo "<a href=\"showreport.php?bugid=$bug[bugid]\">attachment updated</a>";
185 // ###################################################################
187 if ($_REQUEST['do'] == 'edit')
189 if (!(can_perform('caneditattach') OR ($attachment['userid'] == $bugsys->userinfo
['userid'] AND can_perform('canputattach'))))
191 echo 'alert: no permssion';
195 eval('$template->flush("' . $template->fetch('editattach') . '");');
198 /*=====================================================================*\
199 || ###################################################################
202 || ###################################################################
203 \*=====================================================================*/