function checkForAttachments() { global $formObj, $mysqli, $blnCheckForumAttachments, $prevFolder; $returnVal = false; if ($blnCheckForumAttachments) { $attachmentObj = new Download($mysqli); $downloadCatObj = new DownloadCategory($mysqli); $downloadCatObj->selectBySpecialKey("forumattachments"); $forumAttachmentCatID = $downloadCatObj->get_info("downloadcategory_id"); $arrDownloadID = array(); $arrDLColumns = array("downloadcategory_id", "member_id", "dateuploaded", "filename", "mimetype", "filesize", "splitfile1", "splitfile2"); for ($i = 1; $i <= $_POST['numofattachments']; $i++) { $tempPostName = "forumattachment_" . $i; if ($_FILES[$tempPostName]['name'] != "" && $attachmentObj->uploadFile($_FILES[$tempPostName], $prevFolder . "downloads/files/forumattachment/", $forumAttachmentCatID)) { $splitFiles = $attachmentObj->getSplitNames(); $fileSize = $attachmentObj->getFileSize(); $mimeType = $attachmentObj->getMIMEType(); $arrDLValues = array($forumAttachmentCatID, $memberInfo['member_id'], time(), $_FILES[$tempPostName]['name'], $mimeType, $fileSize, "downloads/files/forumattachment/" . $splitFiles[0], "downloads/files/forumattachment/" . $splitFiles[1]); if ($attachmentObj->addNew($arrDLColumns, $arrDLValues)) { $arrDownloadID[] = $attachmentObj->get_info("download_id"); } } elseif ($_FILES[$tempPostName]['name'] != "") { $countErrors++; $dispError .= " <b>·</b> Unable to upload attachment #" . $i . ": " . $_FILES[$tempPostName]['name'] . ".<br>"; } } $returnVal = $arrDownloadID; } return $returnVal; }
$downloadCatObj = new DownloadCategory($mysqli); $downloadObj = new Download($mysqli); $blnShowDownload = false; if ($downloadObj->select($_GET['dID'])) { $downloadInfo = $downloadObj->get_info_filtered(); $downloadCatObj->select($downloadInfo['downloadcategory_id']); $accessType = $downloadCatObj->get_info("accesstype"); if ($accessType == 1 && $LOGGED_IN) { $blnShowDownload = true; } elseif ($accessType == 0) { $blnShowDownload = true; } $fileContents1 = file_get_contents($prevFolder . $downloadInfo['splitfile1']); $fileContents2 = file_get_contents($prevFolder . $downloadInfo['splitfile2']); if ($blnShowDownload && $fileContents1 !== false && $fileContents2 !== false) { $numOfHits = $downloadObj->get_info("downloadcount") + 1; $downloadObj->update(array("downloadcount"), array($numOfHits)); header("Content-Description: File Transfer"); header("Content-Length: " . $downloadInfo['filesize'] . ";"); header("Content-disposition: attachment; filename=" . $downloadInfo['filename']); header("Content-type: " . $downloadInfo['mimetype']); echo $fileContents1 . $fileContents2; } else { echo "File Not Found!"; } } if (!$blnShowDownload) { // Start Page $PAGE_NAME = "Download - "; $dispBreadCrumb = ""; include $prevFolder . "themes/" . $THEME . "/_header.php";