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 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
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 *
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. *
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. *
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, *
36 ************************************************************************/
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
43 // Init include file array as it follows same naming scheme
58 'extensions') as $lib) {
59 // Load special functions
60 loadIncludeOnce('inc/' . $lib . '-functions.php');
63 // Load more function libraries or includes
64 foreach (array('filters', 'mysql-manager', 'handler') as $lib) {
65 // Load special functions
66 loadIncludeOnce('inc/' . $lib . '.php');
70 set_error_handler('__errorHandler');
72 // Disable block-mode by default
73 enableBlockMode(FALSE);
84 // Set important header_sent
85 if (!isset($GLOBALS['__header_sent'])) {
86 $GLOBALS['__header_sent'] = '0';
89 // Init fatal messages
92 // Init repository data sub-system
95 // Enable HTML templates by default
98 // Are we in installation phase?
99 if ((!isInstalling()) && (!isInstallationPhase())) {
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 if ((!empty($GLOBALS['mysql']['host'])) && (!empty($GLOBALS['mysql']['login'])) && (!empty($GLOBALS['mysql']['dbase']))) {
114 SQL_CONNECT($GLOBALS['mysql']['host'], $GLOBALS['mysql']['login'], $GLOBALS['mysql']['password'], __FILE__, __LINE__);
116 // Is the link valid?
117 if (SQL_IS_LINK_UP()) {
118 // Enable exit on error
121 // Is it a valid resource?
122 if (SQL_SELECT_DB($GLOBALS['mysql']['dbase'], __FILE__, __LINE__) === TRUE) {
123 // Set database name (required for ext-optimize and ifSqlTableExists())
124 setConfigEntry('__DB_NAME', $GLOBALS['mysql']['dbase']);
126 // Remove MySQL array from namespace
127 unset($GLOBALS['mysql']);
130 loadIncludeOnce('inc/load_cache.php');
133 reportBug(__FILE__, __LINE__, 'Wrong database selected.');
136 // No link to database!
137 reportBug(__FILE__, __LINE__, 'Database link is not yet up.');
140 // Maybe you forgot to enter your database login?
141 reportBug(__FILE__, __LINE__, 'Database login is missing.');
144 // Default output is 'direct' for HTML output
145 setConfigEntry('OUTPUT_MODE', 'direct');
147 // This hack prevents a backtrace in CSS output
148 if (isCssOutputMode()) {
149 // Problem with config so set output mode
150 setConfigEntry('OUTPUT_MODE', 'render');
153 // CFG: DATABASE-TYPE
154 setConfigEntry('_DB_TYPE', 'mysql3');
156 // Load database layer here
157 loadIncludeOnce('inc/db/lib.php');
159 // Init message system
163 foreach (array('databases', 'session', 'versions', 'install-functions', 'load_config', 'load_cache') as $inc) {
165 loadIncludeOnce('inc/' . $inc . '.php');
171 // Check whether we are in installation routine
172 if ((!isInstalling()) && (!isCssOutputMode()) && (!isRawOutputMode())) {
173 // Redirect to the URL
174 redirectToUrl('install.php');
178 // Handle fatal errors
179 runFilterChain('handle_fatal_errors');