Fixed login form to use redir() instead of hardcoded header() call.
[kolarny.git] / index.php
1 <?php
2 ob_start();
3
4 require_once "config.php";
5 require_once "database.php";
6 require_once "auth.php";
7 require_once "href.php";
8 require_once "autoload.php";
9 require_once "msgbox.php";
10
11 $auth = new Auth();
12 $auth->login(); /* Handle login thru session, if possible */
13
14 if (!isset($_GET['page'])) $page = 'index';
15 else $page = $_GET['page'];
16
17 if (preg_match('/[a-zA-Z_0-9-]+/', $page)) {
18
19         if (!$embed) include "template/head.php";
20
21         if (file_exists("controllers/$page.php")) {
22                 include "controllers/$page.php";
23         } else if (file_exists("template/$page.php")) {
24                 include "template/$page.php";
25         } else {
26                 if (preg_match('/[0-9]+/', $page)) $code = $page;
27                 else $code = 404;
28                 include "controllers/error.php";
29         }
30
31         if (!$embed) include "template/foot.php";
32 } else die("Invalid page format.");
33
34 ?>