3 require_once("boot.php");
7 $debug_text = ''; // Debugging functions should never be used on production systems.
9 // Setup the language and database.
11 $install = ((file_exists('.htconfig.php')) ? false : true);
13 @include(".htconfig.php");
15 // get language setting directly from system variables, bypassing get_config()
16 // as database may not yet be configured.
18 $lang = ((isset($a->config['system']['language'])) ? $a->config['system']['language'] : 'en');
20 load_translation_table($lang);
22 require_once("dba.php");
23 $db = new dba($db_host, $db_user, $db_pass, $db_data, $install);
24 unset($db_host, $db_user, $db_pass, $db_data);
27 require_once("session.php");
29 require_once("datetime.php");
31 date_default_timezone_set(($default_timezone) ? $default_timezone : 'UTC');
37 // header('Link: <' . $a->get_baseurl() . '/amcd>; rel="acct-mgmt";');
39 if((x($_SESSION,'authenticated')) || (x($_POST,'auth-params')) || ($a->module === 'login'))
42 if(! x($_SESSION,'authenticated'))
43 header('X-Account-Management-Status: none');
45 if(! x($_SESSION,'sysmsg'))
46 $_SESSION['sysmsg'] = '';
49 $a->module = 'install';
53 if(strlen($a->module)) {
54 if(file_exists("mod/{$a->module}.php")) {
55 include("mod/{$a->module}.php");
56 $a->module_loaded = true;
59 header($_SERVER["SERVER_PROTOCOL"] . ' 404 ' . t('Not Found'));
60 notice( t('Page not found.' ) . EOL);
64 if($a->module_loaded) {
65 $a->page['page_title'] = $a->module;
66 if(function_exists($a->module . '_init')) {
67 $func = $a->module . '_init';
71 if(($_SERVER['REQUEST_METHOD'] === 'POST') && (! $a->error)
72 && (function_exists($a->module . '_post'))
73 && (! x($_POST,'auth-params'))) {
74 $func = $a->module . '_post';
78 if((! $a->error) && (function_exists($a->module . '_afterpost'))) {
79 $func = $a->module . '_afterpost';
83 if((! $a->error) && (function_exists($a->module . '_content'))) {
84 $func = $a->module . '_content';
85 if(! x($a->page,'content'))
86 $a->page['content'] = '';
87 $a->page['content'] .= $func($a);
92 if(stristr($_SESSION['sysmsg'], t('Permission denied'))) {
93 header($_SERVER["SERVER_PROTOCOL"] . ' 403 ' . t('Permission denied.'));
96 // report anything important happening
98 if(x($_SESSION,'sysmsg')) {
99 $a->page['content'] = "<div id=\"sysmsg\" class=\"error-message\">{$_SESSION['sysmsg']}</div>\r\n"
100 . ((x($a->page,'content')) ? $a->page['content'] : '');
101 unset($_SESSION['sysmsg']);
105 // Feel free to comment out this line on production sites.
106 $a->page['content'] .= $debug_text;
108 $a->page['content'] .= '<div id="pause"></div>';
112 // Navigation (menu) template
113 if($a->module != 'install')
114 require_once("nav.php");
116 // make sure the desired theme exists, though if the default theme doesn't exist we're stuffed.
118 if((x($_SESSION,'theme')) && (! file_exists('view/theme/' . $_SESSION['theme'] . '/style.css')))
119 unset($_SESSION['theme']);
121 $a->page['htmlhead'] = replace_macros($a->page['htmlhead'], array(
122 '$stylesheet' => $a->get_baseurl() . '/view/theme/'
123 . ((x($_SESSION,'theme')) ? $_SESSION['theme'] : 'default')
128 $profile = $a->profile;
130 header("Content-type: text/html; charset=utf-8");
132 $template = 'view/' . $lang . '/'
133 . ((x($a->page,'template')) ? $a->page['template'] : 'default' ) . '.php';
135 if(file_exists($template))
136 require_once($template);
138 require_once(str_replace($lang . '/', '', $template));
140 session_write_close();