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