Debug.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * This file is part of the ForkBB <https://github.com/forkbb>.
  4. *
  5. * @copyright (c) Visman <mio.visman@yandex.ru, https://github.com/MioVisman>
  6. * @license The MIT License (MIT)
  7. */
  8. declare(strict_types=1);
  9. namespace ForkBB\Models\Pages;
  10. use ForkBB\Models\Page;
  11. class Debug extends Page
  12. {
  13. /**
  14. * Подготавливает данные для шаблона
  15. */
  16. public function debug(): Page
  17. {
  18. if ($this->c->isInit('DB')) {
  19. $this->numQueries = $this->c->DB->getCount();
  20. if (
  21. $this->c->DEBUG > 1
  22. && $this->user->isAdmin
  23. ) {
  24. $total = 0;
  25. $queries = $this->c->DB->getQueries();
  26. foreach ($queries as $cur) {
  27. $total += $cur[1];
  28. }
  29. $this->queries = $queries;
  30. $this->total = $total;
  31. }
  32. } else {
  33. $this->numQueries = 0;
  34. }
  35. $this->nameTpl = 'layouts/debug';
  36. $this->onlinePos = null;
  37. $this->memory = \memory_get_usage();
  38. $this->peak = \memory_get_peak_usage();
  39. $this->time = \microtime(true) - $this->c->START;
  40. return $this;
  41. }
  42. /**
  43. * Подготовка страницы к отображению
  44. */
  45. public function prepare(): void
  46. {
  47. }
  48. /**
  49. * Возвращает HTTP заголовки страницы
  50. * $this->httpHeaders
  51. */
  52. protected function getHttpHeaders(): array
  53. {
  54. return [];
  55. }
  56. }