Vaporware imageboard software (planning to pick this back up later this year) https://flash.moe/satoko

index.php 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace Satoko;
  3. if(!defined('STK_ROOT'))
  4. define('STK_ROOT', __DIR__ . '/');
  5. if(!defined('STK_DEBUG'))
  6. define('STK_DEBUG', is_file(STK_ROOT . '/.debug'));
  7. define('STK_PHP_MIN_VER', '7.3.0');
  8. if (version_compare(PHP_VERSION, STK_PHP_MIN_VER, '<')) {
  9. die('Satoko requires PHP <b>' . STK_PHP_MIN_VER . '</b> or newer to run.');
  10. }
  11. error_reporting(STK_DEBUG ? -1 : 0);
  12. ini_set('display_errors', STK_DEBUG ? 'On' : 'Off');
  13. define('STK_CONFIG', STK_ROOT . '/config.ini.php');
  14. if(!is_file(STK_CONFIG))
  15. die('Missing configuration.');
  16. $config = parse_ini_file(STK_ROOT . '/config.ini.php', true, INI_SCANNER_TYPED);
  17. if(!defined('STK_DB_PFX'))
  18. define('STK_DB_PFX', $config['Database']['table_prefix'] ?? 'stk_');
  19. require_once STK_ROOT . 'vendor/autoload.php';
  20. $templates = new Templates([
  21. 'debug' => STK_DEBUG,
  22. 'auto_reload' => STK_DEBUG,
  23. 'cache' => false,
  24. ]);
  25. $router = new Router(
  26. $config['Satoko']['base_path'] ?? '/',
  27. !empty($config['Satoko']['use_path_info'])
  28. );
  29. $router->get(['/', 'index'], function() {
  30. return 'whoa ! images !<br>';
  31. });
  32. $router->get(['/{board}', 'board-index'], function($board) {
  33. return "Viewing {$board}.<br>";
  34. });
  35. $router->dispatch();