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