mirror of https://github.com/MISP/MISP
chg: [internal] Small optimisations
parent
d92123c915
commit
8df77748b0
|
@ -46,8 +46,6 @@ class AppController extends Controller
|
||||||
{
|
{
|
||||||
public $defaultModel = '';
|
public $defaultModel = '';
|
||||||
|
|
||||||
public $debugMode = false;
|
|
||||||
|
|
||||||
public $helpers = array('OrgImg', 'FontAwesome', 'UserName', 'DataPathCollector');
|
public $helpers = array('OrgImg', 'FontAwesome', 'UserName', 'DataPathCollector');
|
||||||
|
|
||||||
private $__queryVersion = '119';
|
private $__queryVersion = '119';
|
||||||
|
@ -175,7 +173,8 @@ class AppController extends Controller
|
||||||
$this->loadModel('Server');
|
$this->loadModel('Server');
|
||||||
$this->Server->serverSettingsSaveValue('MISP.uuid', CakeText::uuid());
|
$this->Server->serverSettingsSaveValue('MISP.uuid', CakeText::uuid());
|
||||||
}
|
}
|
||||||
// check if Apache provides kerberos authentication data
|
|
||||||
|
// Check if Apache provides kerberos authentication data
|
||||||
$authUserFields = $this->User->describeAuthFields();
|
$authUserFields = $this->User->describeAuthFields();
|
||||||
$envvar = Configure::read('ApacheSecureAuth.apacheEnv');
|
$envvar = Configure::read('ApacheSecureAuth.apacheEnv');
|
||||||
if ($envvar && isset($_SERVER[$envvar])) {
|
if ($envvar && isset($_SERVER[$envvar])) {
|
||||||
|
@ -265,19 +264,15 @@ class AppController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->set('default_memory_limit', ini_get('memory_limit'));
|
$this->set('default_memory_limit', ini_get('memory_limit'));
|
||||||
if (isset($user['Role']['memory_limit'])) {
|
if (isset($user['Role']['memory_limit']) && $user['Role']['memory_limit'] !== '') {
|
||||||
if ($user['Role']['memory_limit'] !== '') {
|
ini_set('memory_limit', $user['Role']['memory_limit']);
|
||||||
ini_set('memory_limit', $user['Role']['memory_limit']);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$this->set('default_max_execution_time', ini_get('max_execution_time'));
|
$this->set('default_max_execution_time', ini_get('max_execution_time'));
|
||||||
if (isset($user['Role']['max_execution_time'])) {
|
if (isset($user['Role']['max_execution_time']) && $user['Role']['max_execution_time'] !== '') {
|
||||||
if ($user['Role']['max_execution_time'] !== '') {
|
ini_set('max_execution_time', $user['Role']['max_execution_time']);
|
||||||
ini_set('max_execution_time', $user['Role']['max_execution_time']);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->set('mispVersion', implode('.', array($versionArray['major'], $versionArray['minor'], 0)));
|
$this->set('mispVersion', "{$versionArray['major']}.{$versionArray['minor']}.0");
|
||||||
$this->set('mispVersionFull', $this->mispVersion);
|
$this->set('mispVersionFull', $this->mispVersion);
|
||||||
$this->set('me', $user);
|
$this->set('me', $user);
|
||||||
$role = $user['Role'];
|
$role = $user['Role'];
|
||||||
|
@ -354,7 +349,6 @@ class AppController extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->components['RestResponse']['sql_dump'] = $this->sql_dump;
|
|
||||||
|
|
||||||
// Notifications and homepage is not necessary for AJAX or REST requests
|
// Notifications and homepage is not necessary for AJAX or REST requests
|
||||||
if ($this->Auth->user() && !$this->_isRest() && !$this->request->is('ajax')) {
|
if ($this->Auth->user() && !$this->_isRest() && !$this->request->is('ajax')) {
|
||||||
|
|
|
@ -519,11 +519,12 @@ class RestResponseComponent extends Component
|
||||||
} else {
|
} else {
|
||||||
$type = $format;
|
$type = $format;
|
||||||
}
|
}
|
||||||
|
$dumpSql = !empty($this->Controller->sql_dump) && Configure::read('debug') > 1;
|
||||||
if (!$raw) {
|
if (!$raw) {
|
||||||
if (is_string($response)) {
|
if (is_string($response)) {
|
||||||
$response = array('message' => $response);
|
$response = array('message' => $response);
|
||||||
}
|
}
|
||||||
if (Configure::read('debug') > 1 && !empty($this->Controller->sql_dump)) {
|
if ($dumpSql) {
|
||||||
$this->Log = ClassRegistry::init('Log');
|
$this->Log = ClassRegistry::init('Log');
|
||||||
if ($this->Controller->sql_dump === 2) {
|
if ($this->Controller->sql_dump === 2) {
|
||||||
$response = array('sql_dump' => $this->Log->getDataSource()->getLog(false, false));
|
$response = array('sql_dump' => $this->Log->getDataSource()->getLog(false, false));
|
||||||
|
@ -533,7 +534,7 @@ class RestResponseComponent extends Component
|
||||||
}
|
}
|
||||||
$response = json_encode($response, JSON_PRETTY_PRINT);
|
$response = json_encode($response, JSON_PRETTY_PRINT);
|
||||||
} else {
|
} else {
|
||||||
if (Configure::read('debug') > 1 && !empty($this->Controller->sql_dump)) {
|
if ($dumpSql) {
|
||||||
$this->Log = ClassRegistry::init('Log');
|
$this->Log = ClassRegistry::init('Log');
|
||||||
if ($this->Controller->sql_dump === 2) {
|
if ($this->Controller->sql_dump === 2) {
|
||||||
$response = json_encode(array('sql_dump' => $this->Log->getDataSource()->getLog(false, false)));
|
$response = json_encode(array('sql_dump' => $this->Log->getDataSource()->getLog(false, false)));
|
||||||
|
|
|
@ -2741,7 +2741,7 @@ class AppModel extends Model
|
||||||
{
|
{
|
||||||
static $versionArray;
|
static $versionArray;
|
||||||
if ($versionArray === null) {
|
if ($versionArray === null) {
|
||||||
$file = new File(ROOT . DS . 'VERSION.json', true);
|
$file = new File(ROOT . DS . 'VERSION.json');
|
||||||
$versionArray = $this->jsonDecode($file->read());
|
$versionArray = $this->jsonDecode($file->read());
|
||||||
$file->close();
|
$file->close();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue