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, 2010 by Mailer Developer Team *
20 * For more information visit: http://www.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 // Load more function libraries or includes
44 foreach (array('request-functions', 'session-functions', 'code-functions', 'language-functions', 'sql-functions', 'expression-functions', 'filter-functions','revision-functions', 'filters', 'mysql-manager', 'extensions-functions', 'handler') as $lib) {
45 // Load special functions
46 loadIncludeOnce('inc/' . $lib . '.php');
50 set_error_handler('__errorHandler');
52 // Disable block-mode by default
53 enableBlockMode(false);
64 // Set important header_sent
65 if (!isset($GLOBALS['header_sent'])) $GLOBALS['header_sent'] = '0';
67 // Init fatal messages
70 // Init message system
73 // Init repository data sub-system
76 // Enable HTML templates by default
79 // Are we in installation phase?
80 if ((!isInstalling()) && (!isInstallationPhase())) {
81 // Load configuration file(s) here
82 loadIncludeOnce('inc/load_config.php');
84 // Load database layer here
85 loadIncludeOnce('inc/db/lib.php');
88 initExtensionCssFiles();
90 if ((!empty($GLOBALS['mysql']['host'])) && (!empty($GLOBALS['mysql']['login'])) && (!empty($GLOBALS['mysql']['dbase']))) {
92 SQL_CONNECT($GLOBALS['mysql']['host'], $GLOBALS['mysql']['login'], $GLOBALS['mysql']['password'], __FILE__, __LINE__);
95 if (SQL_IS_LINK_UP()) {
96 // Enable exit on error
99 // Is it a valid resource?
100 if (SQL_SELECT_DB($GLOBALS['mysql']['dbase'], __FILE__, __LINE__) === true) {
101 // This is required for extension 'optimize' to work
102 setConfigEntry('__DB_NAME', $GLOBALS['mysql']['dbase']);
104 // Remove MySQL array from namespace
105 unset($GLOBALS['mysql']);
108 loadIncludeOnce('inc/load_cache.php');
110 // Check module for permissions
111 $checkModule = checkModulePermissions();
113 // Admin module should be accessable by guests to login
114 if ((getModule() == 'admin') && ($checkModule == 'admin_only')) {
115 // This is fine and can be ignored
116 } elseif ($checkModule != 'done') {
118 logDebugMessage(__FILE__, __LINE__, sprintf("Check of module %s results in unexpected value: %s",
125 addFatalMessage(__FILE__, __LINE__, '{--WRONG_DB_SELECTED--}');
128 // No link to database!
129 addFatalMessage(__FILE__, __LINE__, '{--NO_DB_LINK--}');
132 // Maybe you forgot to enter your MySQL data?
133 addFatalMessage(__FILE__, __LINE__, '{--MYSQL_DATA_MISSING--}');
136 // Default output is 'direct' for HTML output
137 setConfigEntry('OUTPUT_MODE', 'direct');
139 // This hack prevents a backtrace in CSS output
140 if (isCssOutputMode()) {
141 // Problem with config so set output mode
142 setConfigEntry('OUTPUT_MODE', 'render');
145 // CFG: DATABASE-TYPE
146 setConfigEntry('_DB_TYPE', 'mysql3');
149 foreach (array('db/lib','databases','session','versions','install-functions','load_config','load_cache') as $inc) {
151 loadIncludeOnce('inc/' . $inc . '.php');
154 // Check wether we are in installation routine
155 if ((!isInstalling()) && (!isCssOutputMode()) && (!isRawOutputMode())) {
156 // Redirect to the URL
157 redirectToUrl('install.php');
161 // Handle fatal errors
162 runFilterChain('handle_fatal_errors');