Index: post.php
===================================================================
--- post.php	(revision 1745)
+++ post.php	(working copy)
@@ -1210,6 +1210,7 @@
 
                 $db->query("UPDATE ".X_PREFIX."posts SET message='$dbmessage', usesig='$usesig', bbcodeoff='$bbcodeoff', smileyoff='$smileyoff', icon='$posticon', subject='$dbsubject' WHERE pid=$pid");
             } else {
+                require_once('include/attach.inc.php');
                 $db->query("DELETE FROM ".X_PREFIX."posts WHERE pid=$pid");
                 $db->query("UPDATE ".X_PREFIX."members SET postnum=postnum-1 WHERE username='".$db->escape_var($orig['author'])."'");
                 deleteAllAttachments($pid);
@@ -1267,9 +1268,10 @@
 
             // Fill $attachment
             $attachment = '';
+            $files = array();
+            if ($forum['attachstatus'] == 'on') {
             $query = $db->query("SELECT a.aid, a.pid, a.filename, a.filetype, a.filesize, a.downloads, a.img_size, thumbs.aid AS thumbid, thumbs.filename AS thumbname, thumbs.img_size AS thumbsize FROM ".X_PREFIX."attachments AS a LEFT JOIN ".X_PREFIX."attachments AS thumbs ON a.aid=thumbs.parentid WHERE a.pid=$pid AND a.parentid=0");
             $counter = 0;
-            $files = array();
             while ($attach = $db->fetch_array($query)) {
                 $files[] = $attach;
                 $postinfo['aid'] = $attach['aid'];
@@ -1301,6 +1303,7 @@
                 eval('$attachment .= "'.template("post_attachmentbox").'";');
             }
             $db->free_result($query);
+            }
 
             //Allow sanitized message to pass-through to template in case of: #1 preview, #2 post error
             $subject = rawHTMLsubject($postinfo['subject']);
