log.php 934 B

12345678910111213141516171819202122232425
  1. <?php
  2. $app->get('/log/{log}', function ($request, $response, $args) {
  3. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  4. if ($Organizr->checkRoute($request)) {
  5. if ($Organizr->qualifyRequest(1, true)) {
  6. $GLOBALS['api']['response']['data'] = $Organizr->getLog($args['log']);
  7. }
  8. }
  9. $response->getBody()->write(jsonE($GLOBALS['api']));
  10. return $response
  11. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  12. ->withStatus($GLOBALS['responseCode']);
  13. });
  14. $app->delete('/log/{log}', function ($request, $response, $args) {
  15. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  16. if ($Organizr->checkRoute($request)) {
  17. if ($Organizr->qualifyRequest(1, true)) {
  18. $Organizr->purgeLog($args['log']);
  19. }
  20. }
  21. $response->getBody()->write(jsonE($GLOBALS['api']));
  22. return $response
  23. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  24. ->withStatus($GLOBALS['responseCode']);
  25. });