]> git.mxchange.org Git - friendica.git/blob - index.php
i18n re-arrange
[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 // header('Link: <' . $a->get_baseurl() . '/amcd>; rel="acct-mgmt";');
34
35 if((x($_SESSION,'authenticated')) || (x($_POST,'auth-params')) || ($a->module === 'login'))
36         require("auth.php");
37
38 if(! x($_SESSION,'authenticated'))
39         header('X-Account-Management-Status: none');
40
41 if(! x($_SESSION,'sysmsg'))
42         $_SESSION['sysmsg'] = '';
43
44 if($install)
45         $a->module = 'install';
46 else
47         check_config($a);
48
49 if(strlen($a->module)) {
50         if(file_exists("mod/{$a->module}.php")) {
51                 include("mod/{$a->module}.php");
52                 $a->module_loaded = true;
53         }
54         else {
55                 header($_SERVER["SERVER_PROTOCOL"] . ' 404 ' . t('Not Found'));
56                 notice( t('Page not found.' ) . EOL);
57         }
58 }
59
60 if($a->module_loaded) {
61         $a->page['page_title'] = $a->module;
62         if(function_exists($a->module . '_init')) {
63                 $func = $a->module . '_init';
64                 $func($a);
65         }
66
67         if(($_SERVER['REQUEST_METHOD'] === 'POST') && (! $a->error)
68                 && (function_exists($a->module . '_post'))
69                 && (! x($_POST,'auth-params'))) {
70                 $func = $a->module . '_post';
71                 $func($a);
72         }
73
74         if((! $a->error) && (function_exists($a->module . '_afterpost'))) {
75                 $func = $a->module . '_afterpost';
76                 $func($a);
77         }
78
79         if((! $a->error) && (function_exists($a->module . '_content'))) {
80                 $func = $a->module . '_content';
81                 if(! x($a->page,'content'))
82                         $a->page['content'] = '';
83                 $a->page['content'] .= $func($a);
84         }
85
86 }
87
88 if(stristr($_SESSION['sysmsg'], t('Permission denied'))) {
89         header($_SERVER["SERVER_PROTOCOL"] . ' 403 ' . t('Permission denied.'));
90 }
91
92 // report anything important happening
93         
94 if(x($_SESSION,'sysmsg')) {
95         $a->page['content'] = "<div id=\"sysmsg\" class=\"error-message\">{$_SESSION['sysmsg']}</div>\r\n"
96                 . ((x($a->page,'content')) ? $a->page['content'] : '');
97         unset($_SESSION['sysmsg']);
98 }
99
100
101 // Feel free to comment out this line on production sites.
102 $a->page['content'] .= $debug_text;
103
104 $a->page['content'] .=  '<div id="pause"></div>';
105 // build page
106
107
108 // Navigation (menu) template
109 if($a->module != 'install')
110         require_once("nav.php");
111
112 // make sure the desired theme exists, though if the default theme doesn't exist we're stuffed.
113
114 if((x($_SESSION,'theme')) && (! file_exists('/view/theme/' . $_SESSION['theme'] . '/style.css')))
115         unset($_SESSION['theme']);
116
117 $a->page['htmlhead'] = replace_macros($a->page['htmlhead'], array(
118         '$stylesheet' => $a->get_baseurl() . '/view/theme/'
119                 . ((x($_SESSION,'theme')) ? $_SESSION['theme'] : 'default')
120                 . '/style.css'
121         ));
122
123 $page    = $a->page;
124 $profile = $a->profile;
125 $lang    = get_config('system','language');
126 if($lang === false)
127         $lang = 'en';
128
129 header("Content-type: text/html; charset=utf-8");
130
131 $template = 'view/' . $lang . '/' 
132         . ((x($a->page,'template')) ? $a->page['template'] : 'default' ) . '.php';
133
134 if(file_exists($template))
135         require_once($template);
136 else
137         require_once(str_replace($lang . '/', '', $template));
138
139 session_write_close();
140 exit;