forked from kohler/peteramati
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
33 lines (30 loc) · 1.11 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
// index.php -- Peteramati home page
// HotCRP and Peteramati are Copyright (c) 2006-2015 Eddie Kohler and others
// Distributed under an MIT-like license; see LICENSE
require_once("lib/navigation.php");
function choose_page($page) {
if ($page !== "" && $page[0] === "~") {
$xpage = Navigation::path_component(0, true);
Navigation::set_path("/" . $page . Navigation::path_suffix(1));
$page = Navigation::set_page($xpage ? : "index");
}
$i = strlen($page) - 4;
if ($i > 0 && substr($page, $i) === ".php")
$page = substr($page, 0, $i);
if ($page === "index")
return null;
if (is_readable($page . ".php")
/* The following is paranoia (currently can't happen): */
&& strpos($page, "/") === false)
return $page . ".php";
else if (preg_match(',\A(?:images|scripts|stylesheets)\z,', $page)) {
$_REQUEST["file"] = $page . Navigation::path();
return "cacheable.php";
} else
Navigation::redirect_site("index");
}
if (($page = choose_page(Navigation::page())))
include $page;
else
require_once("pages/home.php");