chg: [internal] AppController cleanup

pull/7937/head
Jakub Onderka 2021-11-07 14:36:16 +01:00
parent 3459a09943
commit af234a006c
3 changed files with 28 additions and 60 deletions

View File

@ -31,7 +31,7 @@ class AppController extends Controller
*/
public $defaultModel = '';
public $helpers = array('OrgImg', 'FontAwesome', 'UserName', 'DataPathCollector');
public $helpers = array('OrgImg', 'FontAwesome', 'UserName');
private $__queryVersion = '131';
public $pyMispVersion = '2.4.148';
@ -347,7 +347,7 @@ class AppController extends Controller
$this->User->Server->updateDatabase('cleanSessionTable');
}
}
if (Configure::read('site_admin_debug') && (Configure::read('debug') < 2)) {
if (Configure::read('site_admin_debug') && Configure::read('debug') < 2) {
Configure::write('debug', 1);
}
}
@ -378,7 +378,7 @@ class AppController extends Controller
if (!empty($homepage)) {
$this->set('homepage', $homepage);
}
if (version_compare(phpversion(), '8.0') >= 0) {
if (PHP_MAJOR_VERSION >= 8) {
$this->Flash->error(__('WARNING: MISP is currently running under PHP 8.0, which is unsupported. Background jobs will fail, so please contact your administrator to run a supported PHP version (such as 7.4)'));
}
}

View File

@ -1,33 +1,33 @@
<?php
$data = $this->DataPathCollector->extract($row, $field['data_path']);
if ($data['Feed.enabled']) {
if (in_array($data['Feed.source_format'], array('freetext', 'csv'))) {
if ($data['Feed.fixed_event']) {
if (!empty($data['Feed.event_error'])) {
$feed = $row['Feed'];
if ($feed['enabled']) {
if (in_array($feed['source_format'], array('freetext', 'csv'))) {
if ($feed['fixed_event']) {
if (!empty($feed['event_error'])) {
echo sprintf(
'<span class="red bold">%s</span>',
__('Error: Invalid event!')
);
} else {
if ($feed['event_id']) {
echo sprintf(
'<span class="red bold">%s</span>',
__('Error: Invalid event!')
'<a href="%s/events/view/%s">%s</a>',
$baseurl,
h($feed['event_id']),
__('Fixed event %s', h($feed['event_id']))
);
} else {
if ($data['Feed.event_id']) {
echo sprintf(
'<a href="%s/events/view/%s">%s</a>',
$baseurl,
h($data['Feed.event_id']),
__('Fixed event %s', h($data['Feed.event_id']))
);
} else {
echo __('New fixed event');
}
echo __('New fixed event');
}
} else {
echo sprintf(
'<span class="bold red" title="%s">%s</span>',
__('New event each pull can lead to potentially endlessly growing correlation tables. Only use this setting if you are sure that the data in the feed will mostly be completely distinct between each individual pull, otherwise use fixed events. Generally this setting is NOT recommended.'),
__('New event each pull')
);
}
} else {
echo sprintf(
'<span class="bold red" title="%s">%s</span>',
__('New event each pull can lead to potentially endlessly growing correlation tables. Only use this setting if you are sure that the data in the feed will mostly be completely distinct between each individual pull, otherwise use fixed events. Generally this setting is NOT recommended.'),
__('New event each pull')
);
}
} else {
echo __('Feed not enabled');
}
} else {
echo __('Feed not enabled');
}

View File

@ -1,32 +0,0 @@
<?php
/*
* Helper used to extract variables from an array based on path
* Used by the index factories
*
*/
App::uses('AppHelper', 'View/Helper');
class DataPathCollectorHelper extends AppHelper {
public function extract($data, $data_path, $options = array())
{
$result = array();
if (!is_array($data_path)) {
$data_path = array($data_path);
}
foreach ($data_path as $path) {
$temp = Hash::extract($data, $path);
if (is_array($temp)) {
if (count($temp) > 1) {
$temp = implode(', ', $temp);
} else {
if (count($temp) > 0) {
$temp = $temp[0];
} else {
$temp = '';
}
}
}
$result[$path] = $temp;
}
return $result;
}
}