mirror of https://github.com/MISP/MISP
attachments_dir: Default value queried through a function to workaround PHP inability to have anything useful stored in a class property
parent
1ea33e811a
commit
2248846706
|
@ -295,7 +295,7 @@ class AttributesController extends AppController {
|
|||
$attachments_dir = Configure::read('MISP.attachments_dir');
|
||||
if (empty($attachments_dir)) {
|
||||
$this->loadModel('Server');
|
||||
$attachments_dir = $this->Server->serverSettings['MISP']['attachments_dir']['value'];
|
||||
$attachments_dir = $this->Server->getDefaultAttachments_dir();
|
||||
}
|
||||
$path = $attachments_dir . DS . $attribute['event_id'] . DS;
|
||||
$file = $attribute['id'];
|
||||
|
@ -2820,7 +2820,7 @@ class AttributesController extends AppController {
|
|||
$attachments_dir = Configure::read('MISP.attachments_dir');
|
||||
if (empty($attachments_dir)) {
|
||||
$this->loadModel('Server');
|
||||
$attachments_dir = $this->Server->serverSettings['MISP']['attachments_dir']['value'];
|
||||
$attachments_dir = $this->Server->getDefaultAttachments_dir();
|
||||
}
|
||||
foreach ($attributes as $attribute) {
|
||||
$path = $attachments_dir . DS . $attribute['Attribute']['event_id'] . DS;
|
||||
|
|
|
@ -2175,7 +2175,7 @@ class EventsController extends AppController {
|
|||
$attachments_dir = Configure::read('MISP.attachments_dir');
|
||||
if (empty($attachments_dir)) {
|
||||
$this->loadModel('Server');
|
||||
$attachments_dir = $this->Server->serverSettings['MISP']['attachments_dir']['value'];
|
||||
$attachments_dir = $this->Server->getDefaultAttachments_dir();
|
||||
}
|
||||
$rootDir = $attachments_dir . DS . "GFI" . DS . $id . DS;
|
||||
App::uses('Folder', 'Utility');
|
||||
|
@ -2220,7 +2220,7 @@ class EventsController extends AppController {
|
|||
$attachments_dir = Configure::read('MISP.attachments_dir');
|
||||
if (empty($attachments_dir)) {
|
||||
$this->loadModel('Server');
|
||||
$attachments_dir = $this->Server->serverSettings['MISP']['attachments_dir']['value'];
|
||||
$attachments_dir = $this->Server->getDefaultAttachments_dir();
|
||||
}
|
||||
$rootDir = $attachments_dir . DS . $id . DS;
|
||||
App::uses('Folder', 'Utility');
|
||||
|
@ -2390,7 +2390,7 @@ class EventsController extends AppController {
|
|||
$attachments_dir = Configure::read('MISP.attachments_dir');
|
||||
if (empty($attachments_dir)) {
|
||||
$this->loadModel('Server');
|
||||
$attachments_dir = $this->Server->serverSettings['MISP']['attachments_dir']['value'];
|
||||
$attachments_dir = $this->Server->getDefaultAttachments_dir();
|
||||
}
|
||||
$rootDir = $attachments_dir . DS . $id . DS;
|
||||
$malware = $rootDir . DS . 'sample';
|
||||
|
|
|
@ -576,7 +576,7 @@ class Attribute extends AppModel {
|
|||
$attachments_dir = Configure::read('MISP.attachments_dir');
|
||||
if (empty($attachments_dir)) {
|
||||
$my_server = ClassRegistry::init('Server');
|
||||
$attachments_dir = $my_server->serverSettings['MISP']['attachments_dir']['value'];
|
||||
$attachments_dir = $my_server->getDefaultAttachments_dir();
|
||||
}
|
||||
$filepath = $attachments_dir . DS . $this->data['Attribute']['event_id'] . DS . $this->data['Attribute']['id'];
|
||||
$file = new File($filepath);
|
||||
|
@ -1256,7 +1256,7 @@ class Attribute extends AppModel {
|
|||
$attachments_dir = Configure::read('MISP.attachments_dir');
|
||||
if (empty($attachments_dir)) {
|
||||
$my_server = ClassRegistry::init('Server');
|
||||
$attachments_dir = $my_server->serverSettings['MISP']['attachments_dir']['value'];
|
||||
$attachments_dir = $my_server->getDefaultAttachments_dir();
|
||||
}
|
||||
$filepath = $attachments_dir . DS . $attribute['event_id'] . DS . $attribute['id'];
|
||||
$file = new File($filepath);
|
||||
|
@ -1271,7 +1271,7 @@ class Attribute extends AppModel {
|
|||
$attachments_dir = Configure::read('MISP.attachments_dir');
|
||||
if (empty($attachments_dir)) {
|
||||
$my_server = ClassRegistry::init('Server');
|
||||
$attachments_dir = $my_server->serverSettings['MISP']['attachments_dir']['value'];
|
||||
$attachments_dir = $my_server->getDefaultAttachments_dir();
|
||||
}
|
||||
$rootDir = $attachments_dir . DS . $attribute['event_id'];
|
||||
$dir = new Folder($rootDir, true); // create directory structure
|
||||
|
@ -1321,7 +1321,7 @@ class Attribute extends AppModel {
|
|||
$attachments_dir = Configure::read('MISP.attachments_dir');
|
||||
if (empty($attachments_dir)) {
|
||||
$my_server = ClassRegistry::init('Server');
|
||||
$attachments_dir = $my_server->serverSettings['MISP']['attachments_dir']['value'];
|
||||
$attachments_dir = $my_server->getDefaultAttachments_dir();
|
||||
}
|
||||
$rootDir = $attachments_dir . DS . $eventId;
|
||||
$dir = new Folder($rootDir, true);
|
||||
|
@ -2309,7 +2309,7 @@ class Attribute extends AppModel {
|
|||
$attachments_dir = Configure::read('MISP.attachments_dir');
|
||||
if (empty($attachments_dir)) {
|
||||
$my_server = ClassRegistry::init('Server');
|
||||
$attachments_dir = $my_server->serverSettings['MISP']['attachments_dir']['value'];
|
||||
$attachments_dir = $my_server->getDefaultAttachments_dir();
|
||||
}
|
||||
if ($proposal) {
|
||||
$dir = new Folder($attachments_dir . DS . $event_id . DS . 'shadow', true);
|
||||
|
|
|
@ -337,7 +337,7 @@ class Event extends AppModel {
|
|||
$attachments_dir = Configure::read('MISP.attachments_dir');
|
||||
if (empty($attachments_dir)) {
|
||||
$my_server = ClassRegistry::init('Server');
|
||||
$attachments_dir = $my_server->serverSettings['MISP']['attachments_dir']['value'];
|
||||
$attachments_dir = $my_server->getDefaultAttachments_dir();
|
||||
}
|
||||
$filepath = $attachments_dir . DS . $this->id;
|
||||
App::uses('Folder', 'Utility');
|
||||
|
|
|
@ -351,7 +351,7 @@ class Server extends AppModel {
|
|||
'attachments_dir' => array(
|
||||
'level' => 2,
|
||||
'description' => 'Directory where attachments are stored. MISP will NOT migrate the existing data if you change this setting. The only safe way to change this setting is in config.php, when MISP is not running, and after having moved/copied the existing data to the new location. This directory must already exist and be writable and readable by the MISP application.',
|
||||
'value' => APP . 'files',
|
||||
'value' => 'app/files', # GUI display purpose only. Default value defined in func getDefaultAttachments_dir()
|
||||
'errorMessage' => '',
|
||||
'null' => false,
|
||||
'test' => 'testForWritableDir',
|
||||
|
@ -3538,4 +3538,8 @@ class Server extends AppModel {
|
|||
$final .= implode("\n", $output);
|
||||
return $final;
|
||||
}
|
||||
|
||||
public function getDefaultAttachments_dir() {
|
||||
return APP . 'files';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -232,7 +232,7 @@ class ShadowAttribute extends AppModel {
|
|||
$attachments_dir = Configure::read('MISP.attachments_dir');
|
||||
if (empty($attachments_dir)) {
|
||||
$my_server = ClassRegistry::init('Server');
|
||||
$attachments_dir = $my_server->serverSettings['MISP']['attachments_dir']['value'];
|
||||
$attachments_dir = $my_server->getDefaultAttachments_dir();
|
||||
}
|
||||
$filepath = $attachments_dir . DS . 'shadow' . DS . $sa['ShadowAttribute']['event_id'] . DS . $sa['ShadowAttribute']['id'];
|
||||
$file = new File($filepath);
|
||||
|
@ -264,7 +264,7 @@ class ShadowAttribute extends AppModel {
|
|||
$attachments_dir = Configure::read('MISP.attachments_dir');
|
||||
if (empty($attachments_dir)) {
|
||||
$my_server = ClassRegistry::init('Server');
|
||||
$attachments_dir = $my_server->serverSettings['MISP']['attachments_dir']['value'];
|
||||
$attachments_dir = $my_server->getDefaultAttachments_dir();
|
||||
}
|
||||
$filepath = $attachments_dir . DS . 'shadow' . DS . $this->data['ShadowAttribute']['event_id'] . DS . $this->data['ShadowAttribute']['id'];
|
||||
$file = new File($filepath);
|
||||
|
@ -362,7 +362,7 @@ class ShadowAttribute extends AppModel {
|
|||
$attachments_dir = Configure::read('MISP.attachments_dir');
|
||||
if (empty($attachments_dir)) {
|
||||
$my_server = ClassRegistry::init('Server');
|
||||
$attachments_dir = $my_server->serverSettings['MISP']['attachments_dir']['value'];
|
||||
$attachments_dir = $my_server->getDefaultAttachments_dir();
|
||||
}
|
||||
$filepath = $attachments_dir . DS . 'shadow' . DS . $attribute['event_id'] . DS. $attribute['id'];
|
||||
$file = new File($filepath);
|
||||
|
@ -377,7 +377,7 @@ class ShadowAttribute extends AppModel {
|
|||
$attachments_dir = Configure::read('MISP.attachments_dir');
|
||||
if (empty($attachments_dir)) {
|
||||
$my_server = ClassRegistry::init('Server');
|
||||
$attachments_dir = $my_server->serverSettings['MISP']['attachments_dir']['value'];
|
||||
$attachments_dir = $my_server->getDefaultAttachments_dir();
|
||||
}
|
||||
$rootDir = $attachments_dir . DS . 'shadow' . DS . $attribute['event_id'];
|
||||
$dir = new Folder($rootDir, true); // create directory structure
|
||||
|
|
Loading…
Reference in New Issue