fix: use configured attachments_dir instead of app/files/ in ShadowAttributesController.php

pull/3570/head
Xavier Mehrenberger 2018-08-17 17:38:08 +02:00
parent 40f4ea4b75
commit 25871fcd03
1 changed files with 13 additions and 3 deletions

View File

@ -199,8 +199,13 @@ class ShadowAttributesController extends AppController
// If we accept a proposed attachment, then the attachment itself needs to be moved from files/eventId/shadow/shadowId to files/eventId/attributeId
private function _moveFile($shadowId, $newId, $eventId)
{
$pathOld = APP . "files" . DS . $eventId . DS . "shadow" . DS . $shadowId;
$pathNew = APP . "files" . DS . $eventId . DS . $newId;
$attachments_dir = Configure::read('MISP.attachments_dir');
if (empty($attachments_dir)) {
$my_server = ClassRegistry::init('Server');
$attachments_dir = $my_server->getDefaultAttachments_dir();
}
$pathOld = $attachments_dir . DS . 'shadow' . DS . $shadowId;
$pathNew = $attachments_dir . DS . $newId;
if (rename($pathOld, $pathNew)) {
return true;
} else {
@ -499,7 +504,12 @@ class ShadowAttributesController extends AppController
private function __downloadAttachment($shadowAttribute)
{
$path = "files" . DS . 'shadow' . DS . $shadowAttribute['event_id'] . DS;
$attachments_dir = Configure::read('MISP.attachments_dir');
if (empty($attachments_dir)) {
$my_server = ClassRegistry::init('Server');
$attachments_dir = $my_server->getDefaultAttachments_dir();
}
$path = $attachments_dir . DS . 'shadow' . DS . $shadowAttribute['event_id'] . DS;
$file = $shadowAttribute['id'];
if ('attachment' == $shadowAttribute['type']) {
$filename = $shadowAttribute['value'];