----------------global.php---------------------------- if (isset($_REQUEST['attachmentid'])) $attachmentid = $_REQUEST['attachmentid']; if (isset($attachmentid)) { $attachmentid = intval($attachmentid); $attachment = $db->query_first("SELECT bb".$n."_attachments.*, bb".$n."_threads.boardid, bb".$n."_posts.threadid, bb".$n."_posts.visible, bb".$n."_posts.userid FROM bb".$n."_attachments LEFT JOIN bb".$n."_posts ON (bb".$n."_posts.postid=bb".$n."_attachments.postid) LEFT JOIN bb".$n."_threads ON (bb".$n."_threads.threadid=bb".$n."_posts.threadid) WHERE bb".$n."_attachments.attachmentid = '$attachmentid'"); if (!$attachment['attachmentid']) unset($attachmentid); elseif ($attachment['boardid']) { $boardid = $attachment['boardid']; $threadid = $attachment['threadid']; unset($thread); } --------------attachment.php------------------------------ unbuffered_query("UPDATE bb".$n."_attachments SET counter=counter+1 WHERE attachmentid = '$attachmentid'", 1); if (preg_match('/MSIE [0-9]\.[0-9]{1,2}/', $_SERVER['HTTP_USER_AGENT'])) $browser_type = 1; // IE else if (preg_match('/Opera\/[0-9]\.[0-9]{1,2}/', $_SERVER['HTTP_USER_AGENT'])) $browser_type = 2; // Opera else $browser_type = 3; // other... $content_disp = ''; $extension = $attachment['attachmentextension']; if ($extension == 'gif') $mime_type = 'image/gif'; elseif ($extension == 'jpg' || $extension == 'jpeg') $mime_type = 'image/jpeg'; elseif ($extension == 'png') $mime_type = 'image/png'; elseif ($extension == 'pdf') $mime_type = 'application/pdf'; else { if ($browser_type == 1 || $browser_type == 2) $mime_type = 'application/octetstream'; else $mime_type = 'application/octet-stream'; if ($browser_type == 1) $content_disp = 'inline; '; else $content_disp = 'attachment; '; } header('Content-Type: '.$mime_type); header('Content-disposition: '.$content_disp.'filename="'.$attachment['attachmentname'].'.'.$attachment['attachmentextension'].'"'); if ($browser_type == 1) header('Pragma: public'); else header('Pragma: no-cache'); header('Expires: 0'); readfile("attachments/attachment-".$attachment['attachmentid'].".".$attachment['attachmentextension']); } else error($lang->get("LANG_GLOBAL_ERROR_FALSELINK", array('$adminmail' => $adminmail))); ?>