forked from chyrp/chyrp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
executable file
·48 lines (37 loc) · 1.69 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
<?php
if (version_compare(PHP_VERSION, "5.2.0", "<"))
exit("Chyrp requires PHP 5.2.0 or greater.");
require_once "includes/common.php";
# Prepare the controller.
$main = MainController::current();
# Parse the route.
$route = Route::current($main);
# Check if the user can view the site.
if (!$visitor->group->can("view_site") and
!in_array($route->action, array("login", "logout", "register", "lost_password")))
if ($trigger->exists("can_not_view_site"))
$trigger->call("can_not_view_site");
else
show_403(__("Access Denied"), __("You are not allowed to view this site."));
# Execute the appropriate Controller responder.
$route->init();
# If the route failed or nothing was displayed, check for:
# 1. Module-provided pages.
# 2. Feather-provided pages.
# 3. Theme-provided pages.
if (!$route->success and !$main->displayed) {
$displayed = false;
foreach ($config->enabled_modules as $module)
if (file_exists(MODULES_DIR."/".$module."/pages/".$route->action.".php"))
$displayed = require MODULES_DIR."/".$module."/pages/".$route->action.".php";
if (!$displayed)
foreach ($config->enabled_feathers as $feather)
if (file_exists(FEATHERS_DIR."/".$feather."/pages/".$route->action.".php"))
$displayed = require FEATHERS_DIR."/".$feather."/pages/".$route->action.".php";
if (!$displayed and $theme->file_exists("pages/".$route->action))
$main->display("pages/".$route->action);
elseif (!$displayed)
show_404();
}
$trigger->call("end", $route);
ob_end_flush();