WebOrbiton
v1.0.1

AtheraStudio Database

73 lines · 3.3 KB
  1. <?php
  2. declare(strict_types=1);
  3. ​
  4. namespace Athera;
  5. ​
  6. defined('ATHERA') || exit;
  7. ​
  8. final class Page
  9. {
  10. private static function e(string $s): string
  11. {
  12. return htmlspecialchars($s, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
  13. }
  14. ​
  15. private static function tag(): string
  16. {
  17. return substr(hash('sha256', VERSION . '|' . Config::get('APP_KEY')), 0, 12);
  18. }
  19. ​
  20. private static function head(string $title): string
  21. {
  22. $v = '?v=' . self::tag();
  23. return '<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8">'
  24. . '<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">'
  25. . '<meta name="robots" content="noindex, nofollow">'
  26. . '<meta name="referrer" content="same-origin">'
  27. . '<meta name="color-scheme" content="light dark">'
  28. . '<meta name="theme-color" content="#f8fafc">'
  29. . '<title>' . self::e($title) . '</title>'
  30. . '<link rel="icon" href="assets/icon.webp' . $v . '" type="image/webp">'
  31. . '<link rel="stylesheet" href="assets/fonts/fonts.css' . $v . '">'
  32. . '<link rel="stylesheet" href="assets/orbitarium/orbitarium.css' . $v . '">'
  33. . '<link rel="stylesheet" href="assets/app/app.css' . $v . '">'
  34. . '<script src="assets/app/theme.js' . $v . '"></script>'
  35. . '</head>';
  36. }
  37. ​
  38. public static function render(): void
  39. {
  40. Http::securityHeaders(true);
  41. header('Content-Type: text/html; charset=utf-8');
  42. $v = '?v=' . self::tag();
  43. $js = ['orbitarium/orbitarium.js', 'app/icons.js', 'app/i18n.js', 'app/core.js', 'app/grid.js', 'app/editor.js', 'app/atbde.js', 'app/views.js', 'app/table.js', 'app/app.js'];
  44. echo self::head('AtheraStudio Database'), '<body class="orb-app orb-reset" data-version="', self::tag(), '">',
  45. '<div id="app" class="ath-boot"><div class="ath-boot-spin"></div></div>',
  46. '<noscript><p class="ath-noscript">AtheraStudio Database requires JavaScript.</p></noscript>';
  47. foreach ($js as $f) echo '<script src="assets/', $f, $v, '"></script>';
  48. echo '</body></html>';
  49. }
  50. ​
  51. public static function unlock(string $token): void
  52. {
  53. Http::securityHeaders(true);
  54. header('Content-Type: text/html; charset=utf-8');
  55. $done = null;
  56. if (($_SERVER['REQUEST_METHOD'] ?? '') === 'POST') {
  57. $done = Http::sameOrigin() && Security::emergencyUnlock($token);
  58. }
  59. echo self::head('AtheraStudio Database'), '<body class="orb-app orb-reset ath-plain"><main class="ath-unlock orb-card"><div class="orb-card-body">',
  60. '<h1 class="orb-h3">AtheraStudio Database</h1>';
  61. if ($done === null) {
  62. echo '<p>Lift the sign-in lockdown? / Zdjąć blokadę logowania?</p>',
  63. '<form method="post" action="index.php?unlock=', self::e(rawurlencode($token)), '">',
  64. '<button class="orb-btn orb-btn-primary" type="submit">Unlock / Odblokuj</button></form>';
  65. } elseif ($done) {
  66. echo '<p>Lockdown lifted. / Blokada zdjęta.</p><p><a class="orb-btn orb-btn-secondary" href="./">Sign in / Zaloguj</a></p>';
  67. } else {
  68. echo '<p>Link invalid or expired. / Link nieprawidłowy lub wygasł.</p>';
  69. }
  70. echo '</div></main></body></html>';
  71. }
  72. }
  73. ​