2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 11/16/2003 *
4 * =================== Last change: 12/13/2004 *
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 *
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. *
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. *
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, *
31 ************************************************************************/
33 // Some security stuff...
34 if (!defined('__SECURITY')) {
39 $__functions = array();
41 // Init include file array as it follows same naming scheme
57 'extensions') as $lib) {
60 array_push($__functions, $lib . '-functions');
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');
73 set_error_handler('__errorHandler');
75 // Disable block-mode by default
76 enableBlockMode(FALSE);
87 // Set important header_sent
88 if (!isset($GLOBALS['__header_sent'])) {
89 $GLOBALS['__header_sent'] = '0';
92 // Init fatal messages
95 // Enable HTML templates by default
98 // Are we in installation phase?
99 if ((!isInstaller()) && (isInstalled())) {
100 // Load configuration file(s) here
101 loadIncludeOnce('inc/load_config.php');
103 // Load database layer here
104 loadIncludeOnce('inc/db/lib.php');
106 // Init message system
110 initExtensionCssFiles();
112 // Initialize SQL link
115 // Default output is 'direct' for HTML output
116 setConfigEntry('OUTPUT_MODE', 'direct');
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');
125 /* DEBUG: */ logDebugMessage(__FILE__, __LINE__, 'isAjaxOutputMode()=' . intval(isAjaxOutputMode()) . ',isSessionVariableSet(database_extension)=' . intval(isSessionVariableSet('database_extension')));
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'));
134 /* DEBUG: */ logDebugMessage(__FILE__, __LINE__, 'Setting _DB_TYPE to default (mysql) ...');
137 setConfigEntry('_DB_TYPE', 'mysql');
141 unsetSqlLinkUp(__FILE__, __LINE__);
143 // Load database layer here
144 loadIncludeOnce('inc/db/lib.php');
146 // Init message system
153 foreach (array('databases', 'install-functions', 'load_config', 'load_cache') as $inc) {
155 loadIncludeOnce('inc/' . $inc . '.php');
161 // Check whether we are in installation routine
162 if ((!isInstalling()) && (!isCssOutputMode()) && (!isRawOutputMode())) {
163 // Redirect to the URL
164 redirectToUrl('install.php');
168 // Handle fatal errors
169 runFilterChain('handle_fatal_errors');