/** * @desc Obtiene los archivos adjuntos del mensaje * @param bool Devolver objetos {@link BBAttachment} * @param bool Indices del array equivalen al id del objeto * @return array */ function attachments($object = true, $id_as_keys = false) { $result = $this->db->query("SELECT * FROM " . $this->db->prefix("bxpress_attachments") . " WHERE post_id='" . $this->id() . "'"); $ret = array(); while ($row = $this->db->fetchArray($result)) { if ($object) { $attach = new bXAttachment(); $attach->assignVars($row); if ($id_as_keys) { $ret[$row['attach_id']] = $attach; } else { $ret[] = $attach; } } else { if ($id_as_keys) { $ret[$row['attach_id']] = $row; } else { $ret[] = $row; } } } return $ret; }
} // Adjuntamos archivos si existen if ($forum->attachments() && $forum->isAllowed($xoopsUser ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS, 'attach')) { $folder = $xoopsModuleConfig['attachdir']; $exts = array(); include_once RMCPATH . '/class/uploader.php'; $up = new RMFileUploader($folder, $xoopsModuleConfig['maxfilesize'] * 1024, $forum->extensions()); $errors = ''; $filename = ''; if ($up->fetchMedia('attach')) { if (!$up->upload()) { $errors .= $up->getErrors(); } else { $filename = $up->getSavedFileName(); $fullpath = $up->getSavedDestination(); $attach = new bXAttachment(); $attach->setPost($post->id()); $attach->setFile($filename); $attach->setMime($up->getMediaType()); $attach->setDate(time()); $attach->downloads(0); $attach->setName($up->getMediaName()); if (!$attach->save()) { $errors .= $attach->getErrors(); } } } } $topic->setLastPost($post->id()); if (!$create) { $topic->addReply();
// Author: Eduardo Cortés <*****@*****.**> // Email: i.bitcero@gmail.com // License: GPL 2.0 // -------------------------------------------------------------- /** * @desc Archivo para procesar la entrega de archivos adjuntos */ define('BB_LOCATION', 'files'); include '../../mainfile.php'; $id = rmc_server_var($_GET, 'id', 0); $topic = rmc_server_var($_GET, 'topic', 0); if ($id <= 0) { redirect_header('topic.php?id=' . $topic, 2, __('No topic has been specified!', 'bxpress')); die; } $attach = new bXAttachment($id); if ($attach->isNew()) { redirect_header('topic.php?id=' . $topic, 2, __('Specified file does not exists!', 'bxpress')); die; } if (!file_exists(XOOPS_UPLOAD_PATH . '/bxpress/' . $attach->file())) { redirect_header('topics.php', 2, __('Specified file does not exists!', 'bxpress')); die; } $ext = substr($attach->file(), strrpos($attach->file(), '.')); header('Content-type: ' . $attach->mime()); header('Cache-control: no-store'); header('Expires: 0'); header('Content-disposition: attachment; filename=' . urlencode($attach->name() . $ext)); header('Content-Transfer-Encoding: binary'); header('Content-Lenght: ' . filesize(XOOPS_UPLOAD_PATH . '/bxpress/' . $attach->file()));