vito / chyrp

The ultra-lightweight ultra-flexible blogging engine with a fetish for birds and misspellings.

This URL has Read+Write access

chyrp / index.php
100755 74 lines (60 sloc) 2.773 kb
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
65
66
67
68
69
70
71
72
73
74
<?php
    if (version_compare(PHP_VERSION, "5.1.3", "<"))
        exit("Chyrp requires PHP 5.1.3 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();
 
# error("Database Error", "Unknown column 'users.where' in 'where clause'
#
# <pre>SELECT users.*
# FROM users
# WHERE (users.where IN ('alex'))
# ORDER BY users.id DESC
#
#
# <pre>Array
# (
# )
# </pre>
#
# <pre>#0 /var/www/rosiba/includes/class/SQL.php(201): Query->__construct(Object(SQL), 'SELECT users.*?...', Array, false)
# #1 /var/www/rosiba/includes/class/SQL.php(238): SQL->query('SELECT __users....', Array, false)
# #2 /var/www/rosiba/includes/class/Model.php(155): SQL->select(Array, Array, Array, 'id DESC', Array, NULL, NULL, Array, Array)
# #3 /var/www/rosiba/includes/model/User.php(19): Model::grab(Object(User), Array, Array)
# #4 /var/www/rosiba/includes/model/Post.php(684): User->__construct(Array)
# #5 /var/www/rosiba/includes/controller/Main.php(374): Post::from_url(Array, Array)
# #6 [internal function]: MainController->view(Array)
# #7 /var/www/rosiba/includes/class/Route.php(99): call_user_func_array(Array, Array)
# #8 /var/www/rosiba/index.php(22): Route->init()
# #9 {main}</pre>");
 
    # 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();