In newreply.php and newthread.php replace this:
PHP Code:
// **************************************** \\
// *** Keep attachments when previewing *** \\
// **************************************** \\
$postinfo = $DB_site->query_first('
SELECT attachmentid, filename FROM attachment
WHERE attachmentid = '.intval($HTTP_POST_VARS['attachmentid']).' AND visible = 0
');
if (intval($HTTP_POST_VARS['attachmentid']) != 0 and $postinfo) {
$oldattachid = $postinfo['attachmentid'];
} else {
unset($oldattachid);
}
if ($orphans = $DB_site->query("SELECT a.attachmentid FROM attachment AS a LEFT JOIN post USING (attachmentid) WHERE postid IS NULL") and $DB_site->num_rows($orphans) > 0) {
$orphanids = '0';
while ($orphan = $DB_site->fetch_array($orphans)) {
$orphanids .= ",$orphan[attachmentid]";
}
$DB_site->query("DELETE FROM attachment WHERE attachmentid IN ($orphanids) AND dateline < ".(time() - (60*15))." AND attachmentid <> ".intval($oldattachid));
}
// **************************************** \\
// *** Keep attachments when previewing *** \\
// **************************************** \\
With this:
PHP Code:
// **************************************** \\
// *** Keep attachments when previewing *** \\
// **************************************** \\
$postinfo = $DB_site->query_first('
SELECT attachmentid, filename FROM attachment
WHERE attachmentid = '.intval($HTTP_POST_VARS['attachmentid']).' AND visible = 0
');
if (intval($HTTP_POST_VARS['attachmentid']) != 0 and $postinfo) {
$oldattachid = $postinfo['attachmentid'];
} else {
unset($oldattachid);
}
if ($orphans = $DB_site->query("
SELECT a.attachmentid
FROM attachment AS a
LEFT JOIN post ON (post.attachmentid = a.attachmentid)
LEFT JOIN privatemessage ON (privatemessage.attachmentid = a.attachmentid)
WHERE postid IS NULL AND privatemessageid IS NULL
") and $DB_site->num_rows($orphans) > 0) {
$orphanids = '0';
while ($orphan = $DB_site->fetch_array($orphans)) {
$orphanids .= ",$orphan[attachmentid]";
}
$DB_site->query("DELETE FROM attachment WHERE attachmentid IN ($orphanids) AND dateline < ".(time() - (60*15))." AND attachmentid <> ".intval($oldattachid));
}
// **************************************** \\
// *** Keep attachments when previewing *** \\
// **************************************** \\