]> git.mxchange.org Git - friendica.git/blob - index.php
photo editing
[friendica.git] / index.php
1 <?php
2
3 require_once("boot.php");
4
5 $a = new App;
6
7 $debug_text = ''; // Debugging functions should never be used on production systems.
8
9 // Setup the database.
10
11 $install = ((file_exists('.htconfig.php')) ? false : true);
12
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);
17
18 require_once("session.php");
19 require_once("datetime.php");
20
21 date_default_timezone_set(($default_timezone) ? $default_timezone : 'UTC');
22
23 $a->init_pagehead();
24
25 session_start();
26
27 if((x($_SESSION,'authenticated')) || (x($_POST['auth-params'])))
28         require("auth.php");
29
30 if($install)
31         $a->module = 'install';
32
33 if(strlen($a->module)) {
34         if(file_exists("mod/{$a->module}.php")) {
35                 include("mod/{$a->module}.php");
36                 $a->module_loaded = true;
37         }
38         else {
39                 notice( t('Page not found' ) . EOL);
40         }
41 }
42
43 // invoke module functions
44 // Important: Modules normally do not emit content, unless you need it for debugging.
45 // The module_init, module_post, and module_afterpost functions process URL parameters and POST processing.
46 // The module_content function returns content text to this file where it is included on the page.
47 // Modules emitting XML/Atom, etc. should do so idirectly and promptly exit before the HTML page can be rendered.
48 // "Most" HTML resides in the view directory as text templates with macro substitution. 
49 // They look like HTML with PHP variables but only a couple pass through the PHP processor - those with .php extensions.
50 // The macro substitution is defined per page for the .tpl files. 
51 // Information transfer between functions can be accomplished via the App session '$a' and its related variables.
52 // x() queries both a variable's existence and that it is "non-zero" or "non-empty" depending on how it is called. 
53 // q() is the SQL query form. All string (%s) variables MUST be passed through dbesc(). 
54 // All int values MUST be cast to integer using intval(); 
55
56 if($a->module_loaded) {
57         $a->page['page_title'] = $a->module;
58         if(function_exists($a->module . '_init')) {
59                 $func = $a->module . '_init';
60                 $func($a);
61         }
62
63         if(($_SERVER['REQUEST_METHOD'] == 'POST') && (! $a->error)
64                 && (function_exists($a->module . '_post'))
65                 && (! x($_POST,'auth-params'))) {
66                 $func = $a->module . '_post';
67                 $func($a);
68         }
69
70         if((! $a->error) && (function_exists($a->module . '_afterpost'))) {
71                 $func = $a->module . '_afterpost';
72                 $func($a);
73         }
74
75         if((! $a->error) && (function_exists($a->module . '_content'))) {
76                 $func = $a->module . '_content';
77                 $a->page['content'] .= $func($a);
78         }
79
80         footer($a);
81 }
82
83 // report anything important happening
84         
85 if(x($_SESSION,'sysmsg')) {
86         $a->page['content'] = "<div id=\"sysmsg\" class=\"error-message\">{$_SESSION['sysmsg']}</div>\r\n"
87                 . $a->page['content'];
88         unset($_SESSION['sysmsg']);
89 }
90
91 // Feel free to comment out this line on production sites.
92 $a->page['content'] .= $debug_text;
93
94 // build page
95
96 // Navigation (menu) template
97 require_once("nav.php");
98
99 $page    = $a->page;
100 $profile = $a->profile;
101
102 header("Content-type: text/html; charset=utf-8");
103 $template = "view/" 
104         . ((x($a->page,'theme')) ? $a->page['theme'] . '/' : "" ) 
105         . ((x($a->page,'template')) ? $a->page['template'] : 'default' ) 
106         . ".php";
107
108 require_once($template);
109
110 session_write_close();
111 exit;