mirror of https://github.com/MISP/MISP
new: [API] SQL dump now includes two modes
- sql_dump:1 - append the SQL dump to the response - sql_dump:2 - only return the SQL dump in the responsepull/5404/head
parent
21088005d4
commit
463b98c275
|
@ -124,7 +124,7 @@ class AppController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($this->params['named']['sql'])) {
|
if (!empty($this->params['named']['sql'])) {
|
||||||
$this->sql_dump = 1;
|
$this->sql_dump = intval($this->params['named']['sql']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_setupDatabaseConnection();
|
$this->_setupDatabaseConnection();
|
||||||
|
|
|
@ -446,17 +446,25 @@ class RestResponseComponent extends Component
|
||||||
}
|
}
|
||||||
if (Configure::read('debug') > 1 && !empty($this->Controller->sql_dump)) {
|
if (Configure::read('debug') > 1 && !empty($this->Controller->sql_dump)) {
|
||||||
$this->Log = ClassRegistry::init('Log');
|
$this->Log = ClassRegistry::init('Log');
|
||||||
$response['sql_dump'] = json_encode($this->Log->getDataSource()->getLog(false, false));
|
if ($this->Content->sql_dump === 2) {
|
||||||
|
$response = array('sql_dump' => $this->Log->getDataSource()->getLog(false, false));
|
||||||
|
} else {
|
||||||
|
$response['sql_dump'] = $this->Log->getDataSource()->getLog(false, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$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 (Configure::read('debug') > 1 && !empty($this->Controller->sql_dump)) {
|
||||||
$this->Log = ClassRegistry::init('Log');
|
$this->Log = ClassRegistry::init('Log');
|
||||||
$response = substr_replace(
|
if ($this->Controller->sql_dump === 2) {
|
||||||
$response,
|
$response = json_encode(array('sql_dump' => $this->Log->getDataSource()->getLog(false, false)));
|
||||||
sprintf(', "sql_dump": %s}', json_encode($this->Log->getDataSource()->getLog(false, false))),
|
} else {
|
||||||
-2
|
$response = substr_replace(
|
||||||
);
|
$response,
|
||||||
|
sprintf(', "sql_dump": %s}', json_encode($this->Log->getDataSource()->getLog(false, false))),
|
||||||
|
-2
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue