]> git.mxchange.org Git - friendica.git/blob - index.php
stronger type checking on comparisons
[friendica.git] / index.php
1 <?php
2
3 require_once("boot.php");
4
5 $a = new App;
6
7 $debug_text = ''; // Debugging functions should never be used on production systems.
8
9 // Setup the database.
10
11 $install = ((file_exists('.htconfig.php')) ? false : true);
12
13 @include(".htconfig.php");
14 require_once("dba.php");
15 $db = new dba($db_host, $db_user, $db_pass, $db_data, $install);
16         unset($db_host, $db_user, $db_pass, $db_data);
17
18 if(! $install)
19         require_once("session.php");
20
21 require_once("datetime.php");
22
23 date_default_timezone_set(($default_timezone) ? $default_timezone : 'UTC');
24
25 $a->init_pagehead();
26
27 session_start();
28
29
30 if((x($_SESSION,'authenticated')) || (x($_POST['auth-params'])))
31         require("auth.php");
32
33 if($install)
34         $a->module = 'install';
35 else
36         check_config($a);
37
38 if(strlen($a->module)) {
39         if(file_exists("mod/{$a->module}.php")) {
40                 include("mod/{$a->module}.php");
41                 $a->module_loaded = true;
42         }
43         else {
44                 header($_SERVER["SERVER_PROTOCOL"] . ' 404 ' . t('Not Found'));
45                 notice( t('Page not found.' ) . EOL);
46         }
47 }
48
49 if($a->module_loaded) {
50         $a->page['page_title'] = $a->module;
51         if(function_exists($a->module . '_init')) {
52                 $func = $a->module . '_init';
53                 $func($a);
54         }
55
56         if(($_SERVER['REQUEST_METHOD'] === 'POST') && (! $a->error)
57                 && (function_exists($a->module . '_post'))
58                 && (! x($_POST,'auth-params'))) {
59                 $func = $a->module . '_post';
60                 $func($a);
61         }
62
63         if((! $a->error) && (function_exists($a->module . '_afterpost'))) {
64                 $func = $a->module . '_afterpost';
65                 $func($a);
66         }
67
68         if((! $a->error) && (function_exists($a->module . '_content'))) {
69                 $func = $a->module . '_content';
70                 $a->page['content'] .= $func($a);
71         }
72
73 }
74
75 if(stristr($_SESSION['sysmsg'], t('Permission denied'))) {
76         header($_SERVER["SERVER_PROTOCOL"] . ' 403 ' . t('Permission denied.'));
77 }
78
79 // report anything important happening
80         
81 if(x($_SESSION,'sysmsg')) {
82         $a->page['content'] = "<div id=\"sysmsg\" class=\"error-message\">{$_SESSION['sysmsg']}</div>\r\n"
83                 . $a->page['content'];
84         unset($_SESSION['sysmsg']);
85 }
86
87 // Feel free to comment out this line on production sites.
88 $a->page['content'] .= $debug_text;
89 $a->page['content'] .= '<div id="pause"></div>';
90 // build page
91
92
93 // Navigation (menu) template
94 if($a->module != 'install')
95         require_once("nav.php");
96
97 $a->page['htmlhead'] = replace_macros($a->page['htmlhead'], array(
98         '$stylesheet' => $a->get_baseurl() . '/view/theme/'
99                 . ((x($_SESSION,'theme')) ? $_SESSION['theme'] : 'default')
100                 . '/style.css'
101         ));
102
103 $page    = $a->page;
104 $profile = $a->profile;
105 $lang    = get_config('system','language');
106
107 header("Content-type: text/html; charset=utf-8");
108
109 $template = "view/" . (($lang) ? $lang . "/" : "") 
110         . ((x($a->page,'template')) ? $a->page['template'] : 'default' ) 
111         . ".php";
112
113 require_once($template);
114
115 session_write_close();
116 exit;