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.

87 lignes
2.2KB

  1. <?php
  2. require_once("inc/functions.php");
  3. require_once("inc/route.php");
  4. require_once("inc/controller.php");
  5. if (!$config["smart_build_helper"]) {
  6. die('You need to enable $config["smart_build_helper"]');
  7. }
  8. $config['smart_build'] = false; // Let's disable it, so we can build the page for real
  9. $config['generation_strategies'] = array('strategy_immediate');
  10. function after_open_board() { global $config;
  11. $config['smart_build'] = false;
  12. $config['generation_strategies'] = array('strategy_immediate');
  13. };
  14. $request = $_SERVER['REQUEST_URI'];
  15. $route = route($request);
  16. if (!$route) {
  17. $reached = false;
  18. }
  19. else {
  20. list ($fun, $args) = $route;
  21. $reached = call_user_func_array($fun, $args);
  22. }
  23. function die_404() { global $config;
  24. if (!$config['page_404']) {
  25. header("HTTP/1.1 404 Not Found");
  26. header("Status: 404 Not Found");
  27. echo "<h1>404 Not Found</h1><p>Page doesn't exist<hr><address>vichan</address>";
  28. }
  29. else {
  30. header("Location: ".$config['page_404']);
  31. }
  32. header("X-Accel-Expires: 120");
  33. die();
  34. }
  35. if ($reached) {
  36. if ($request[strlen($request)-1] == '/') {
  37. $request .= 'index.html';
  38. }
  39. $request = '.'.$request;
  40. if (!file_exists($request)) {
  41. die_404();
  42. }
  43. header("HTTP/1.1 200 OK");
  44. header("Status: 200 OK");
  45. if (preg_match('/\.json$/', $request)) {
  46. header("Content-Type", "application/json");
  47. }
  48. elseif (preg_match('/\.js$/', $request)) {
  49. header("Content-Type", "text/javascript; charset=utf-8");
  50. }
  51. elseif (preg_match('/\.xml$/', $request)) {
  52. header("Content-Type", "application/xml");
  53. }
  54. elseif (preg_match('/\.rss$/', $request)) {
  55. header("Content-Type", "application/rss+xml");
  56. }
  57. else {
  58. header("Content-Type", "text/html; charset=utf-8");
  59. }
  60. header("Cache-Control: public, nocache, no-cache, max-age=0, must-revalidate");
  61. header("Expires: Fri, 22 Feb 1991 06:00:00 GMT");
  62. header("Last-Modified: ".date('r', filemtime($request)));
  63. //if (isset ($_SERVER['HTTP_ACCEPT_ENCODING']) && preg_match('/gzip/', $_SERVER['HTTP_ACCEPT_ENCODING']) && file_exists($request.".gz")) {
  64. // header("Content-Encoding: gzip");
  65. // $file = fopen($request.".gz", 'r');
  66. //}
  67. //else {
  68. $file = fopen($request, 'r');
  69. //}
  70. fpassthru($file);
  71. fclose($file);
  72. }
  73. else {
  74. die_404();
  75. }