3 require_once("boot.php");
7 $debug_text = ''; // Debugging functions should never be used on production systems.
11 $install = ((file_exists('.htconfig.php')) ? false : true);
13 @include(".htconfig.php");
14 require_once("dba.php");
15 $db = new dba($db_host, $db_user, $db_pass, $db_data, $install);
16 unset($db_host, $db_user, $db_pass, $db_data);
19 require_once("session.php");
21 require_once("datetime.php");
23 date_default_timezone_set(($default_timezone) ? $default_timezone : 'UTC');
29 if((x($_SESSION,'authenticated')) || (x($_POST['auth-params'])))
33 $a->module = 'install';
37 if(strlen($a->module)) {
38 if(file_exists("mod/{$a->module}.php")) {
39 include("mod/{$a->module}.php");
40 $a->module_loaded = true;
43 header($_SERVER["SERVER_PROTOCOL"] . ' 404 ' . t('Not Found'));
44 notice( t('Page not found' ) . EOL);
48 // invoke module functions
49 // Important: Modules normally do not emit content, unless you need it for debugging.
50 // The module_init, module_post, and module_afterpost functions process URL parameters and POST processing.
51 // The module_content function returns content text to this file where it is included on the page.
52 // Modules emitting XML/Atom, etc. should do so idirectly and promptly exit before the HTML page can be rendered.
53 // "Most" HTML resides in the view directory as text templates with macro substitution.
54 // They look like HTML with PHP variables but only a couple pass through the PHP processor - those with .php extensions.
55 // The macro substitution is defined per page for the .tpl files.
56 // Information transfer between functions can be accomplished via the App session '$a' and its related variables.
57 // x() queries both a variable's existence and that it is "non-zero" or "non-empty" depending on how it is called.
58 // q() is the SQL query form. All string (%s) variables MUST be passed through dbesc().
59 // All int values MUST be cast to integer using intval();
61 if($a->module_loaded) {
62 $a->page['page_title'] = $a->module;
63 if(function_exists($a->module . '_init')) {
64 $func = $a->module . '_init';
68 if(($_SERVER['REQUEST_METHOD'] == 'POST') && (! $a->error)
69 && (function_exists($a->module . '_post'))
70 && (! x($_POST,'auth-params'))) {
71 $func = $a->module . '_post';
75 if((! $a->error) && (function_exists($a->module . '_afterpost'))) {
76 $func = $a->module . '_afterpost';
80 if((! $a->error) && (function_exists($a->module . '_content'))) {
81 $func = $a->module . '_content';
82 $a->page['content'] .= $func($a);
87 // report anything important happening
89 if(x($_SESSION,'sysmsg')) {
90 $a->page['content'] = "<div id=\"sysmsg\" class=\"error-message\">{$_SESSION['sysmsg']}</div>\r\n"
91 . $a->page['content'];
92 unset($_SESSION['sysmsg']);
95 if(stristr($_SESSION['sysmsg'], t('Permission denied'))) {
96 header($_SERVER["SERVER_PROTOCOL"] . ' 403 ' . t('Permission denied.'));
100 // Feel free to comment out this line on production sites.
101 $a->page['content'] .= $debug_text;
105 // Navigation (menu) template
106 if($a->module != 'install')
107 require_once("nav.php");
110 $profile = $a->profile;
112 header("Content-type: text/html; charset=utf-8");
114 . ((x($a->page,'theme')) ? $a->page['theme'] . '/' : "" )
115 . ((x($a->page,'template')) ? $a->page['template'] : 'default' )
118 require_once($template);
120 session_write_close();