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