protected function handleResponse($message = null, $code = null, $success = true, array $data = null) { if (!$success) { header('HTTP/1.1 500 Internal Server Error'); } header('Content-Type: application/json'); header(self::API_VER_HEADER . ': ' . self::API_VER); $latest_logs = null; try { $latest_logs = $this->module->getLatestLogLines(); } catch (Exception $e) { // } echo json_encode(array('status' => $success ? 'OK' : 'KO', 'status_message' => $message, 'status_code' => $code, 'data' => (array) $data, 'request' => array_filter(array(isset($_POST) ? (array) $_POST : null, isset($_GET) ? (array) $_GET : null)), 'notify_apiver' => self::API_VER, 'sysinfo' => $this->module->getSysinfo(), 'log' => $latest_logs)); exit(0); }