Opps, not all elements for sprintf() has been set.
[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 } else {
114         // Default output is 'direct' for HTML output
115         setConfigEntry('OUTPUT_MODE', 'direct');
116
117         // This hack prevents a backtrace in CSS output
118         if (isCssOutputMode()) {
119                 // Problem with config so set output mode
120                 setConfigEntry('OUTPUT_MODE', 'render');
121         } // END - if
122
123         // CFG: DATABASE-TYPE
124         setConfigEntry('_DB_TYPE', 'mysql');
125
126         // Set link as down
127         unsetSqlLinkUp(__FILE__, __LINE__);
128
129         // Load database layer here
130         loadIncludeOnce('inc/db/lib.php');
131
132         // Init message system
133         initMessages();
134
135         // Init session
136         initSession();
137
138         // Include more
139         foreach (array('databases', 'install-functions', 'load_config', 'load_cache') as $inc) {
140                 // Load include file
141                 loadIncludeOnce('inc/' . $inc . '.php');
142         } // END - foreach
143
144         // Init installer
145         initInstaller();
146
147         // Check whether we are in installation routine
148         if ((!isInstalling()) && (!isCssOutputMode()) && (!isRawOutputMode())) {
149                 // Redirect to the URL
150                 redirectToUrl('install.php');
151         } // END - if
152 }
153
154 // Handle fatal errors
155 runFilterChain('handle_fatal_errors');
156
157 // [EOF]
158 ?>