forked from kohler/hotcrp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
64 lines (60 loc) · 2.23 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
// index.php -- HotCRP home page
// Copyright (c) 2006-2020 Eddie Kohler; see LICENSE.
require_once("lib/navigation.php");
$nav = Navigation::get();
// handle `/u/USERINDEX/`
if ($nav->page === "u") {
$unum = $nav->path_component(0);
if ($unum !== false && ctype_digit($unum)) {
if (!$nav->shift_path_components(2)) {
// redirect `/u/USERINDEX` => `/u/USERINDEX/`
Navigation::redirect($nav->server . $nav->base_path . "u/" . $unum . "/" . $nav->query);
}
} else {
// redirect `/u/XXXX` => `/`
Navigation::redirect($nav->server . $nav->base_path . $nav->query);
}
}
function gx_call_requests(Conf $conf, Contact $user, Qrequest $qreq, $group, GroupedExtensions $gx) {
$gx->add_xt_checker([$qreq, "xt_allow"]);
$reqgj = [];
$not_allowed = false;
foreach ($gx->members($group, "request_callback") as $gj) {
if ($gx->allowed($gj->allow_request_if ?? null, $gj)) {
$reqgj[] = $gj;
} else {
$not_allowed = true;
}
}
if ($not_allowed && $qreq->is_post() && !$qreq->valid_token()) {
$conf->msg($conf->_i("badpost"), 2);
}
foreach ($reqgj as $gj) {
if ($gx->call_callback($gj->request_callback, $gj) === false) {
break;
}
}
}
// handle special pages
if ($nav->page === "images" || $nav->page === "scripts" || $nav->page === "stylesheets") {
$_GET["file"] = $nav->page . $nav->path;
include("cacheable.php");
} else if ($nav->page === "api" || $nav->page === "cacheable" || $nav->page === "scorechart") {
include("{$nav->page}.php");
} else {
require_once("src/initweb.php");
$gx = $Conf->page_partials($Me);
$pagej = $gx->get($nav->page);
if (!$pagej || str_starts_with($pagej->name, "__")) {
header("HTTP/1.0 404 Not Found");
} else if ($Me->is_disabled() && !($pagej->allow_disabled ?? false)) {
header("HTTP/1.0 403 Forbidden");
} else if (isset($pagej->render_php)) {
include($pagej->render_php);
} else {
$gx->set_context(["root" => $pagej->group, "args" => [$Me, $Qreq, $gx]]);
gx_call_requests($Conf, $Me, $Qreq, $pagej->group, $gx);
$gx->render_group($pagej->group, ["top" => true]);
}
}