getDB(); } catch (Exception $e) { http_response_code(500); exit; } $res = $sqlite->query("SELECT value FROM config WHERE key='token'"); if ($sqlite->res2single($res) != $INPUT->str('token')) { http_response_code(403); exit; } $res = $sqlite->query('SELECT id, timestamp, user, message_html FROM log ORDER BY timestamp DESC LIMIT ?', $INPUT->int('limit', -1)); $arr = $sqlite->res2arr($res); echo json_encode($arr);