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 if(isset($lang) && strlen($lang))
16 load_translation_table($lang);
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);
23 require_once("session.php");
25 require_once("datetime.php");
27 date_default_timezone_set(($default_timezone) ? $default_timezone : 'UTC');
33 // header('Link: <' . $a->get_baseurl() . '/amcd>; rel="acct-mgmt";');
35 if((x($_SESSION,'authenticated')) || (x($_POST,'auth-params')) || ($a->module === 'login'))
38 if(! x($_SESSION,'authenticated'))
39 header('X-Account-Management-Status: none');
41 if(! x($_SESSION,'sysmsg'))
42 $_SESSION['sysmsg'] = '';
45 $a->module = 'install';
49 if(strlen($a->module)) {
50 if(file_exists("mod/{$a->module}.php")) {
51 include("mod/{$a->module}.php");
52 $a->module_loaded = true;
55 header($_SERVER["SERVER_PROTOCOL"] . ' 404 ' . t('Not Found'));
56 notice( t('Page not found.' ) . EOL);
60 if($a->module_loaded) {
61 $a->page['page_title'] = $a->module;
62 if(function_exists($a->module . '_init')) {
63 $func = $a->module . '_init';
67 if(($_SERVER['REQUEST_METHOD'] === 'POST') && (! $a->error)
68 && (function_exists($a->module . '_post'))
69 && (! x($_POST,'auth-params'))) {
70 $func = $a->module . '_post';
74 if((! $a->error) && (function_exists($a->module . '_afterpost'))) {
75 $func = $a->module . '_afterpost';
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);
88 if(stristr($_SESSION['sysmsg'], t('Permission denied'))) {
89 header($_SERVER["SERVER_PROTOCOL"] . ' 403 ' . t('Permission denied.'));
92 // report anything important happening
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']);
101 // Feel free to comment out this line on production sites.
102 $a->page['content'] .= $debug_text;
104 $a->page['content'] .= '<div id="pause"></div>';
108 // Navigation (menu) template
109 if($a->module != 'install')
110 require_once("nav.php");
112 // make sure the desired theme exists, though if the default theme doesn't exist we're stuffed.
114 if((x($_SESSION,'theme')) && (! file_exists('/view/theme/' . $_SESSION['theme'] . '/style.css')))
115 unset($_SESSION['theme']);
117 $a->page['htmlhead'] = replace_macros($a->page['htmlhead'], array(
118 '$stylesheet' => $a->get_baseurl() . '/view/theme/'
119 . ((x($_SESSION,'theme')) ? $_SESSION['theme'] : 'default')
124 $profile = $a->profile;
125 $lang = get_config('system','language');
129 header("Content-type: text/html; charset=utf-8");
131 $template = 'view/' . $lang . '/'
132 . ((x($a->page,'template')) ? $a->page['template'] : 'default' ) . '.php';
134 if(file_exists($template))
135 require_once($template);
137 require_once(str_replace($lang . '/', '', $template));
139 session_write_close();