2010-07-01 19:48:07 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once("boot.php");
|
|
|
|
|
|
|
|
$a = new App;
|
|
|
|
|
|
|
|
$debug_text = ''; // Debugging functions should never be used on production systems.
|
|
|
|
|
2010-10-06 20:40:58 -04:00
|
|
|
// Setup the language and database.
|
2010-07-01 19:48:07 -04:00
|
|
|
|
|
|
|
$install = ((file_exists('.htconfig.php')) ? false : true);
|
|
|
|
|
|
|
|
@include(".htconfig.php");
|
2010-10-06 20:40:58 -04:00
|
|
|
|
2010-12-07 21:13:51 -05:00
|
|
|
// get language setting directly from system variables, bypassing get_config()
|
|
|
|
// as database may not yet be configured.
|
|
|
|
|
|
|
|
$lang = ((isset($a->config['system']['language'])) ? $a->config['system']['language'] : 'en');
|
|
|
|
|
|
|
|
load_translation_table($lang);
|
2010-10-06 20:40:58 -04:00
|
|
|
|
2010-07-01 19:48:07 -04:00
|
|
|
require_once("dba.php");
|
|
|
|
$db = new dba($db_host, $db_user, $db_pass, $db_data, $install);
|
2010-11-06 08:07:10 -04:00
|
|
|
unset($db_host, $db_user, $db_pass, $db_data);
|
2010-07-01 19:48:07 -04:00
|
|
|
|
2010-08-16 00:49:29 -04:00
|
|
|
if(! $install)
|
|
|
|
require_once("session.php");
|
|
|
|
|
2010-07-01 19:48:07 -04:00
|
|
|
require_once("datetime.php");
|
|
|
|
|
|
|
|
date_default_timezone_set(($default_timezone) ? $default_timezone : 'UTC');
|
|
|
|
|
|
|
|
$a->init_pagehead();
|
|
|
|
|
|
|
|
session_start();
|
|
|
|
|
2010-11-11 17:53:39 -05:00
|
|
|
// header('Link: <' . $a->get_baseurl() . '/amcd>; rel="acct-mgmt";');
|
2010-08-16 08:23:26 -04:00
|
|
|
|
2010-11-11 05:49:28 -05:00
|
|
|
if((x($_SESSION,'authenticated')) || (x($_POST,'auth-params')) || ($a->module === 'login'))
|
2010-07-01 19:48:07 -04:00
|
|
|
require("auth.php");
|
|
|
|
|
2010-11-11 05:49:28 -05:00
|
|
|
if(! x($_SESSION,'authenticated'))
|
|
|
|
header('X-Account-Management-Status: none');
|
|
|
|
|
2010-10-31 19:38:22 -04:00
|
|
|
if(! x($_SESSION,'sysmsg'))
|
|
|
|
$_SESSION['sysmsg'] = '';
|
|
|
|
|
2010-07-01 19:48:07 -04:00
|
|
|
if($install)
|
|
|
|
$a->module = 'install';
|
2010-08-14 21:11:36 -04:00
|
|
|
else
|
|
|
|
check_config($a);
|
2010-07-01 19:48:07 -04:00
|
|
|
|
|
|
|
if(strlen($a->module)) {
|
|
|
|
if(file_exists("mod/{$a->module}.php")) {
|
|
|
|
include("mod/{$a->module}.php");
|
|
|
|
$a->module_loaded = true;
|
|
|
|
}
|
|
|
|
else {
|
2010-08-09 00:03:08 -04:00
|
|
|
header($_SERVER["SERVER_PROTOCOL"] . ' 404 ' . t('Not Found'));
|
2010-09-08 23:14:17 -04:00
|
|
|
notice( t('Page not found.' ) . EOL);
|
2010-07-01 19:48:07 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if($a->module_loaded) {
|
|
|
|
$a->page['page_title'] = $a->module;
|
|
|
|
if(function_exists($a->module . '_init')) {
|
|
|
|
$func = $a->module . '_init';
|
|
|
|
$func($a);
|
|
|
|
}
|
|
|
|
|
2010-09-26 20:24:20 -04:00
|
|
|
if(($_SERVER['REQUEST_METHOD'] === 'POST') && (! $a->error)
|
2010-07-01 19:48:07 -04:00
|
|
|
&& (function_exists($a->module . '_post'))
|
|
|
|
&& (! x($_POST,'auth-params'))) {
|
|
|
|
$func = $a->module . '_post';
|
|
|
|
$func($a);
|
|
|
|
}
|
|
|
|
|
|
|
|
if((! $a->error) && (function_exists($a->module . '_afterpost'))) {
|
|
|
|
$func = $a->module . '_afterpost';
|
|
|
|
$func($a);
|
|
|
|
}
|
|
|
|
|
|
|
|
if((! $a->error) && (function_exists($a->module . '_content'))) {
|
|
|
|
$func = $a->module . '_content';
|
2010-10-31 19:38:22 -04:00
|
|
|
if(! x($a->page,'content'))
|
|
|
|
$a->page['content'] = '';
|
|
|
|
$a->page['content'] .= $func($a);
|
2010-07-01 19:48:07 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-09-08 23:14:17 -04:00
|
|
|
if(stristr($_SESSION['sysmsg'], t('Permission denied'))) {
|
|
|
|
header($_SERVER["SERVER_PROTOCOL"] . ' 403 ' . t('Permission denied.'));
|
|
|
|
}
|
|
|
|
|
2010-07-01 19:48:07 -04:00
|
|
|
// report anything important happening
|
|
|
|
|
|
|
|
if(x($_SESSION,'sysmsg')) {
|
2010-08-03 22:34:33 -04:00
|
|
|
$a->page['content'] = "<div id=\"sysmsg\" class=\"error-message\">{$_SESSION['sysmsg']}</div>\r\n"
|
2010-11-07 18:46:49 -05:00
|
|
|
. ((x($a->page,'content')) ? $a->page['content'] : '');
|
2010-07-01 19:48:07 -04:00
|
|
|
unset($_SESSION['sysmsg']);
|
|
|
|
}
|
|
|
|
|
2010-10-17 23:04:17 -04:00
|
|
|
|
2010-07-01 19:48:07 -04:00
|
|
|
// Feel free to comment out this line on production sites.
|
|
|
|
$a->page['content'] .= $debug_text;
|
2010-09-30 01:11:26 -04:00
|
|
|
|
|
|
|
$a->page['content'] .= '<div id="pause"></div>';
|
2010-07-01 19:48:07 -04:00
|
|
|
// build page
|
|
|
|
|
2010-09-20 22:34:44 -04:00
|
|
|
|
2010-07-01 19:48:07 -04:00
|
|
|
// Navigation (menu) template
|
2010-08-16 00:49:29 -04:00
|
|
|
if($a->module != 'install')
|
|
|
|
require_once("nav.php");
|
2010-07-01 19:48:07 -04:00
|
|
|
|
2010-11-04 03:37:29 -04:00
|
|
|
// make sure the desired theme exists, though if the default theme doesn't exist we're stuffed.
|
|
|
|
|
2010-12-07 21:13:51 -05:00
|
|
|
if((x($_SESSION,'theme')) && (! file_exists('view/theme/' . $_SESSION['theme'] . '/style.css')))
|
2010-11-04 03:37:29 -04:00
|
|
|
unset($_SESSION['theme']);
|
|
|
|
|
2010-08-16 08:23:26 -04:00
|
|
|
$a->page['htmlhead'] = replace_macros($a->page['htmlhead'], array(
|
|
|
|
'$stylesheet' => $a->get_baseurl() . '/view/theme/'
|
|
|
|
. ((x($_SESSION,'theme')) ? $_SESSION['theme'] : 'default')
|
|
|
|
. '/style.css'
|
|
|
|
));
|
|
|
|
|
2010-07-01 19:48:07 -04:00
|
|
|
$page = $a->page;
|
|
|
|
$profile = $a->profile;
|
|
|
|
|
|
|
|
header("Content-type: text/html; charset=utf-8");
|
2010-08-16 08:23:26 -04:00
|
|
|
|
2010-11-16 02:27:12 -05:00
|
|
|
$template = 'view/' . $lang . '/'
|
|
|
|
. ((x($a->page,'template')) ? $a->page['template'] : 'default' ) . '.php';
|
2010-07-01 19:48:07 -04:00
|
|
|
|
2010-11-16 02:27:12 -05:00
|
|
|
if(file_exists($template))
|
|
|
|
require_once($template);
|
|
|
|
else
|
|
|
|
require_once(str_replace($lang . '/', '', $template));
|
2010-07-01 19:48:07 -04:00
|
|
|
|
|
|
|
session_write_close();
|
|
|
|
exit;
|