d3c8afd80de9953d1bb5d211368738cba41b7527
[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 - 2013 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                 'filter',
56                 'extensions') as $lib) {
57
58         // Add it
59         array_push($__functions, $lib . '-functions');
60 } // END - foreach
61
62 // Load more function libraries or includes
63 foreach (array_merge($__functions, array('filters', 'mysql-manager', 'handler')) as $lib) {
64         // Load special functions
65         loadIncludeOnce('inc/' . $lib . '.php');
66 } // END - foreach
67
68 // Remove array
69 unset($__functions);
70
71 // Set error handler
72 set_error_handler('__errorHandler');
73
74 // Disable block-mode by default
75 enableBlockMode(FALSE);
76
77 // Init error handler
78 initErrorHandler();
79
80 // Init request
81 initRequest();
82
83 // Init userid
84 initMemberId();
85
86 // Set important header_sent
87 if (!isset($GLOBALS['__header_sent'])) {
88         $GLOBALS['__header_sent'] = '0';
89 } // END - if
90
91 // Init fatal messages
92 initFatalMessages();
93
94 // Enable HTML templates by default
95 enableTemplateHtml();
96
97 // Are we in installation phase?
98 if ((!isInstaller()) && (isInstalled())) {
99         // Load configuration file(s) here
100         loadIncludeOnce('inc/load_config.php');
101
102         // Load database layer here
103         loadIncludeOnce('inc/db/lib.php');
104
105         // Init message system
106         initMessages();
107
108         // CSS array
109         initExtensionCssFiles();
110
111         // Initialize SQL link
112         initSqlLink();
113
114         // Init session
115         initSession();
116 } else {
117         // Default output is 'direct' for HTML output
118         setConfigEntry('OUTPUT_MODE', 'direct');
119
120         // This hack prevents a backtrace in CSS output
121         if (isCssOutputMode()) {
122                 // Problem with config so set output mode
123                 setConfigEntry('OUTPUT_MODE', 'render');
124         } // END - if
125
126         // CFG: DATABASE-TYPE
127         setConfigEntry('_DB_TYPE', 'mysql');
128
129         // Set link as down
130         unsetSqlLinkUp(__FILE__, __LINE__);
131
132         // Load database layer here
133         loadIncludeOnce('inc/db/lib.php');
134
135         // Init message system
136         initMessages();
137
138         // Init session
139         initSession();
140
141         // Include more
142         foreach (array('databases', 'install-functions', 'load_config', 'load_cache') as $inc) {
143                 // Load include file
144                 loadIncludeOnce('inc/' . $inc . '.php');
145         } // END - foreach
146
147         // Init installer
148         initInstaller();
149
150         // Check whether we are in installation routine
151         if ((!isInstalling()) && (!isCssOutputMode()) && (!isRawOutputMode())) {
152                 // Redirect to the URL
153                 redirectToUrl('install.php');
154         } // END - if
155 }
156
157 // Handle fatal errors
158 runFilterChain('handle_fatal_errors');
159
160 // [EOF]
161 ?>