Tried to fix installer a bit + added missing language string.
[mailer.git] / inc / mysql-connect.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 11/16/2003 *
4  * ===================                          Last change: 12/13/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : mysql-connect.php                                *
8  * -------------------------------------------------------------------- *
9  * Short description : Connects to your database                        *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Verbindet zu Ihrer Datenbank                     *
12  * -------------------------------------------------------------------- *
13  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
14  * Copyright (c) 2009 - 2015 by Mailer Developer Team                   *
15  * For more information visit: http://mxchange.org                      *
16  *                                                                      *
17  * This program is free software; you can redistribute it and/or modify *
18  * it under the terms of the GNU General Public License as published by *
19  * the Free Software Foundation; either version 2 of the License, or    *
20  * (at your option) any later version.                                  *
21  *                                                                      *
22  * This program is distributed in the hope that it will be useful,      *
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
25  * GNU General Public License for more details.                         *
26  *                                                                      *
27  * You should have received a copy of the GNU General Public License    *
28  * along with this program; if not, write to the Free Software          *
29  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
30  * MA  02110-1301  USA                                                  *
31  ************************************************************************/
32
33 // Some security stuff...
34 if (!defined('__SECURITY')) {
35         die();
36 } // END - if
37
38 // Init array
39 $__functions = array();
40
41 // Init include file array as it follows same naming scheme
42 foreach ( array(
43                 'stats',
44                 'xml',
45                 'callback',
46                 'referral',
47                 'email',
48                 'request',
49                 'session',
50                 'code',
51                 'pool',
52                 'language',
53                 'sql',
54                 'expression',
55                 'encryption',
56                 'filter',
57                 'extensions') as $lib) {
58
59         // Add it
60         array_push($__functions, $lib . '-functions');
61 } // END - foreach
62
63 // Load more function libraries or includes
64 foreach (array_merge($__functions, array('filters', 'mysql-manager', 'handler')) as $lib) {
65         // Load special functions
66         loadIncludeOnce('inc/' . $lib . '.php');
67 } // END - foreach
68
69 // Remove array
70 unset($__functions);
71
72 // Set error handler
73 set_error_handler('__errorHandler');
74
75 // Disable block-mode by default
76 enableBlockMode(FALSE);
77
78 // Init error handler
79 initErrorHandler();
80
81 // Init request
82 initRequest();
83
84 // Init userid
85 initMemberId();
86
87 // Set important header_sent
88 if (!isset($GLOBALS['__header_sent'])) {
89         $GLOBALS['__header_sent'] = '0';
90 } // END - if
91
92 // Init fatal messages
93 initFatalMessages();
94
95 // Enable HTML templates by default
96 enableTemplateHtml();
97
98 // Are we in installation phase?
99 if ((!isInstaller()) && (isInstalled())) {
100         // Load configuration file(s) here
101         loadIncludeOnce('inc/load_config.php');
102
103         // Load database layer here
104         loadIncludeOnce('inc/db/lib.php');
105
106         // Init message system
107         initMessages();
108
109         // CSS array
110         initExtensionCssFiles();
111
112         // Initialize SQL link
113         initSqlLink();
114 } else {
115         // Default output is 'direct' for HTML output
116         setConfigEntry('OUTPUT_MODE', 'direct');
117
118         // This hack prevents a backtrace in CSS output
119         if (isCssOutputMode()) {
120                 // Problem with config so set output mode
121                 setConfigEntry('OUTPUT_MODE', 'render');
122         } // END - if
123
124         // Debug message
125         /* DEBUG: */ logDebugMessage(__FILE__, __LINE__, 'isAjaxOutputMode()=' . intval(isAjaxOutputMode()) . ',isSessionVariableSet(database_extension)=' . intval(isSessionVariableSet('database_extension')));
126
127         // Is it AJAX call and database_extension is set?
128         if ((isAjaxOutputMode()) && (isSessionVariableSet('database_extension'))) {
129                 // Then take it from session
130                 /* DEBUG: */ logDebugMessage(__FILE__, __LINE__, 'Setting _DB_TYPE from session;database_extension=' . getSession('database_extension'));
131                 setConfigEntry('_DB_TYPE', getSession('database_extension'));
132         } else {
133                 // Debug message
134                 /* DEBUG: */ logDebugMessage(__FILE__, __LINE__, 'Setting _DB_TYPE to default (mysql) ...');
135
136                 // Set (old) default
137                 setConfigEntry('_DB_TYPE', 'mysql');
138         }
139
140         // Set link as down
141         unsetSqlLinkUp(__FILE__, __LINE__);
142
143         // Load database layer here
144         loadIncludeOnce('inc/db/lib.php');
145
146         // Init message system
147         initMessages();
148
149         // Init session
150         initSession();
151
152         // Include more
153         foreach (array('databases', 'install-functions', 'load_config', 'load_cache') as $inc) {
154                 // Load include file
155                 loadIncludeOnce('inc/' . $inc . '.php');
156         } // END - foreach
157
158         // Init installer
159         initInstaller();
160
161         // Check whether we are in installation routine
162         if ((!isInstalling()) && (!isCssOutputMode()) && (!isRawOutputMode())) {
163                 // Redirect to the URL
164                 redirectToUrl('install.php');
165         } // END - if
166 }
167
168 // Handle fatal errors
169 runFilterChain('handle_fatal_errors');
170
171 // [EOF]
172 ?>