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);
18 require_once("session.php");
19 require_once("datetime.php");
21 date_default_timezone_set(($default_timezone) ? $default_timezone : 'UTC');
27 if((x($_SESSION,'authenticated')) || (x($_POST['auth-params'])))
31 $a->module = 'install';
33 if(strlen($a->module)) {
34 if(file_exists("mod/{$a->module}.php")) {
35 include("mod/{$a->module}.php");
36 $a->module_loaded = true;
40 // search builtin function module table, else
41 // return 403, 404, etc. Right now unresolved pages return blank.
45 // invoke module functions
46 // Important: Modules normally do not emit content, unless you need it for debugging.
47 // The module_init, module_post, and module_afterpost functions process URL parameters and POST processing.
48 // The module_content function returns content text to this function where it is included on the page.
49 // Modules emitting XML/Atom, etc. should do so in the _init function and promptly exit.
50 // "Most" HTML resides in the view directory as text templates with macro substitution.
51 // They look like HTML with PHP variables but only a couple pass through the PHP processor - those with .php extensions.
52 // The macro substitution is defined per page for the .tpl files.
53 // Information transfer between functions can be accomplished via the App session '$a' and its related variables.
54 // x() queries both a variable's existence and that it is "non-zero" or "non-empty" depending on how it is called.
55 // q() is the SQL query form. All string (%s) variables MUST be passed through dbesc().
56 // All int values MUST be cast to integer using intval();
58 if($a->module_loaded) {
59 $a->page['page_title'] = $a->module;
60 if(function_exists($a->module . '_init')) {
61 $func = $a->module . '_init';
65 if(($_SERVER['REQUEST_METHOD'] == 'POST') && (! $a->error)
66 && (function_exists($a->module . '_post'))
67 && (! x($_POST,'auth-params'))) {
68 $func = $a->module . '_post';
72 if((! $a->error) && (function_exists($a->module . '_afterpost'))) {
73 $func = $a->module . '_afterpost';
77 if((! $a->error) && (function_exists($a->module . '_content'))) {
78 $func = $a->module . '_content';
79 $a->page['content'] .= $func($a);
85 // report anything important happening
87 if(x($_SESSION,'sysmsg')) {
88 $a->page['content'] = "<div class=\"error-message\">{$_SESSION['sysmsg']}</div>\r\n"
89 . $a->page['content'];
90 unset($_SESSION['sysmsg']);
93 // Feel free to comment out this line on production sites.
94 $a->page['content'] .= $debug_text;
98 // Navigation (menu) template
99 require_once("nav.php");
102 $profile = $a->profile;
104 header("Content-type: text/html; charset=utf-8");
106 . ((x($a->page,'theme')) ? $a->page['theme'] . '/' : "" )
107 . ((x($a->page,'template')) ? $a->page['template'] : 'default' )
110 require_once($template);
112 session_write_close();