The version of vichan running on lainchan.org
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

66 lignes
2.1KB

  1. <?php
  2. // vichan's routing mechanism
  3. // don't bother with that unless you use smart build or advanced build
  4. // you can use those parts for your own implementations though :^)
  5. defined('TINYBOARD') or exit;
  6. function route($path) { global $config;
  7. $entrypoints = array();
  8. $entrypoints['/%b/'] = 'sb_board';
  9. $entrypoints['/%b/'.$config['file_index']] = 'sb_board';
  10. $entrypoints['/%b/'.$config['file_page']] = 'sb_board';
  11. $entrypoints['/%b/%d.json'] = 'sb_api_board';
  12. if ($config['api']['enabled']) {
  13. $entrypoints['/%b/threads.json'] = 'sb_api';
  14. $entrypoints['/%b/catalog.json'] = 'sb_api';
  15. }
  16. $entrypoints['/%b/'.$config['dir']['res'].$config['file_page']] = 'sb_thread_slugcheck';
  17. $entrypoints['/%b/'.$config['dir']['res'].$config['file_page50']] = 'sb_thread_slugcheck50';
  18. if ($config['slugify']) {
  19. $entrypoints['/%b/'.$config['dir']['res'].$config['file_page_slug']] = 'sb_thread_slugcheck';
  20. $entrypoints['/%b/'.$config['dir']['res'].$config['file_page50_slug']] = 'sb_thread_slugcheck50';
  21. }
  22. if ($config['api']['enabled']) {
  23. $entrypoints['/%b/'.$config['dir']['res'].'%d.json'] = 'sb_thread';
  24. }
  25. $entrypoints['/*/'] = 'sb_ukko';
  26. $entrypoints['/*/index.html'] = 'sb_ukko';
  27. $entrypoints['/recent.html'] = 'sb_recent';
  28. $entrypoints['/%b/catalog.html'] = 'sb_catalog';
  29. $entrypoints['/%b/index.rss'] = 'sb_catalog';
  30. $entrypoints['/sitemap.xml'] = 'sb_sitemap';
  31. $entrypoints = array_merge($entrypoints, $config['controller_entrypoints']);
  32. $reached = false;
  33. list($request) = explode('?', $path);
  34. foreach ($entrypoints as $id => $fun) {
  35. $id = '@^' . preg_quote($id, '@') . '$@u';
  36. $id = str_replace('%b', '('.$config['board_regex'].')', $id);
  37. $id = str_replace('%d', '([0-9]+)', $id);
  38. $id = str_replace('%s', '[a-zA-Z0-9-]+', $id);
  39. $matches = null;
  40. if (preg_match ($id, $request, $matches)) {
  41. array_shift($matches);
  42. $reached = array($fun, $matches);
  43. break;
  44. }
  45. }
  46. return $reached;
  47. }