]>
src.bluestatic.org Git - bugdar.git/blob - attachment.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 \*=====================================================================*/
13 $fetchtemplates = array (
20 require_once ( './global.php' );
22 if ( isset ( $bugsys- > in
[ 'attachmentid' ]))
24 $attachment = $db- > query_first ( "SELECT * FROM " . TABLE_PREFIX
. "attachment WHERE attachmentid = " . intval ( $bugsys- > in
[ 'attachmentid' ]));
27 echo 'alert: bad attachment' ;
32 $bug = $db- > query_first ( "SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid = " . intval ( $bugsys- > in
[ 'bugid' ]));
35 echo 'alert: bad bug' ;
39 // ###################################################################
41 if ( $_REQUEST [ 'do' ] == 'kill' )
43 // run code to remove item in database
46 // ###################################################################
48 if ( $_REQUEST [ 'do' ] == 'delete' )
50 // display delete confirmation message
53 // ###################################################################
55 if ( $_POST [ 'do' ] == 'insert' )
57 if (! can_perform ( 'canputattach' ))
59 echo 'alert: no permission' ;
64 $FILE =& $_FILES [ 'attachment' ];
67 switch ( $FILE [ 'error' ])
70 case 1 : echo 'PHP said the file you uploaded was too big.' ; exit ; break ;
71 case 2 : echo 'The file exceeds the allowed upload size.' ; exit ; break ;
72 case 3 : echo 'The file was only partially uploaded.' ; exit ; break ;
73 case 4 : echo 'The file was not uploaded at all.' ; exit ; break ;
74 case 6 : echo 'PHP could not find the /tmp directory.' ; exit ; break ;
78 if (! is_uploaded_file ( $FILE [ 'tmp_name' ]))
80 echo 'The file you specified did not upload.' ;
84 // put some MIME-type validation here
86 if (! $bugsys- > in
[ 'description' ])
88 echo 'you need a file description!' ;
92 $filedata = $bugsys- > escape ( file_get_contents ( $FILE [ 'tmp_name' ]), true , true );
95 // insert an attachment
97 INSERT INTO attachment
98 (bugid, filename, mimetype, filesize,
99 attachment, description, dateline, userid)
101 ( $bug [bugid], '" . $bugsys- > escape ( $FILE [ 'name' ]) . "',
102 '" . $bugsys- > escape ( $FILE [ 'type' ]) . "', " . intval ( $FILE [ 'size' ]) . ",
103 ' $filedata' , '" . $bugsys- > in
[ 'description' ] . "', $time ,
104 " . $bugsys- > userinfo
[ 'userid' ] . "
109 $obsoletes = $_POST [ 'obsoletes' ];
110 array_walk ( $obsoletes , 'intval' );
111 $db- > query ( "UPDATE " . TABLE_PREFIX
. "attachment SET obsolete = 1 WHERE attachmentid IN (" . implode ( ',' , $obsoletes ) . ") AND !obsolete AND bugid = $bug [bugid]" );
113 // handle comment stuff
114 if ( can_perform ( 'canpostcomments' ) AND trim ( $bugsys- > in
[ 'comment' ]))
116 $bugsys- > in
[ 'comment_parsed' ] = $bugsys- > in
[ 'comment' ];
118 if (! $bugsys- > options
[ 'allowhtml' ])
120 $bugsys- > in
[ 'comment_parsed' ] = $bugsys- > sanitize ( $bugsys- > in
[ 'comment_parsed' ]);
124 INSERT INTO " . TABLE_PREFIX
. "comment
125 (bugid, userid, dateline, comment, comment_parsed)
127 ( $bug [bugid], " . $bugsys- > userinfo
[ 'userid' ] . ",
128 $time , '" . $bugsys- > in
[ 'comment' ] . "',
129 '" . nl2br ( $bugsys- > in
[ 'comment_parsed' ]) . "'
134 // update the last post data
135 $db- > query ( "UPDATE " . TABLE_PREFIX
. "bug SET lastposttime = $time , lastpostby = " . $bugsys- > userinfo
[ 'userid' ] . " WHERE bugid = $bug [bugid]" );
137 echo "<a href= \" showreport.php?bugid= $bug [bugid] \" >attachment added</a>" ;
141 // ###################################################################
143 if ( $_REQUEST [ 'do' ] == 'add' )
145 if (! can_perform ( 'canputattach' ))
147 echo 'alert: no permission' ;
151 $MAXFILESIZE = $funct- > fetch_max_attachment_size ();
153 $show [ 'addcomment' ] = (( can_perform ( 'canpostcomments' )) ? true : false );
154 $show [ 'obsoletes' ] = false ;
156 $obsoletes_fetch = $db- > query ( "SELECT * FROM " . TABLE_PREFIX
. "attachment WHERE bugid = $bug [bugid] AND !obsolete" );
158 while ( $obsolete = $db- > fetch_array ( $obsoletes_fetch ))
160 $show [ 'obsoletes' ] = true ;
161 $obsoletes .= "<div><input name= \" obsoletes[] \" type= \" checkbox \" value= \" $obsolete [attachmentid] \" /> $obsolete [filename] [ $obsolete [description]]</div> \n " ;
164 eval ( ' $template- >flush("' . $template- > fetch ( 'newattach' ) . '");' );
167 // ###################################################################
169 if ( $_POST [ 'do' ] == 'update' )
171 // run code to update item in database
174 // ###################################################################
176 if ( $_REQUEST [ 'do' ] == 'edit' )
178 // display form to edit item
181 /*=====================================================================*\
182 || ###################################################################
185 || ###################################################################
186 \*=====================================================================*/