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 * Needs to be in all Files and every File needs "svn propset *
18 * svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
19 * -------------------------------------------------------------------- *
20 * Copyright (c) 2003 - 2009 by Roland Haeder *
21 * Copyright (c) 2009, 2010 by Mailer Developer Team *
22 * For more information visit: http://www.mxchange.org *
24 * This program is free software; you can redistribute it and/or modify *
25 * it under the terms of the GNU General Public License as published by *
26 * the Free Software Foundation; either version 2 of the License, or *
27 * (at your option) any later version. *
29 * This program is distributed in the hope that it will be useful, *
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
32 * GNU General Public License for more details. *
34 * You should have received a copy of the GNU General Public License *
35 * along with this program; if not, write to the Free Software *
36 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
38 ************************************************************************/
40 // Some security stuff...
41 if (!defined('__SECURITY')) {
45 // Load more function libraries or includes
46 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) {
47 // Load special functions
48 loadIncludeOnce('inc/' . $lib . '.php');
52 set_error_handler('__errorHandler');
54 // Disable block-mode by default
55 enableBlockMode(false);
66 // Set important header_sent
67 if (!isset($GLOBALS['header_sent'])) $GLOBALS['header_sent'] = '0';
69 // Init fatal messages
72 // Init message system
75 // Enable HTML templates by default
78 // Are we in installation phase?
79 if ((!isInstalling()) && (!isInstallationPhase())) {
80 // Load configuration file(s) here
81 loadIncludeOnce('inc/load_config.php');
83 // Load database layer here
84 loadIncludeOnce('inc/db/lib.php');
87 initExtensionCssFiles();
89 if ((!empty($GLOBALS['mysql']['host'])) && (!empty($GLOBALS['mysql']['login'])) && (!empty($GLOBALS['mysql']['dbase']))) {
91 SQL_CONNECT($GLOBALS['mysql']['host'], $GLOBALS['mysql']['login'], $GLOBALS['mysql']['password'], __FILE__, __LINE__);
94 if (SQL_IS_LINK_UP()) {
95 // Enable exit on error
98 // Is it a valid resource?
99 if (SQL_SELECT_DB($GLOBALS['mysql']['dbase'], __FILE__, __LINE__) === true) {
100 // This is required for extension 'optimize' to work
101 setConfigEntry('__DB_NAME', $GLOBALS['mysql']['dbase']);
103 // Remove MySQL array from namespace
104 unset($GLOBALS['mysql']);
107 loadIncludeOnce('inc/load_cache.php');
109 // Check module for permissions
110 $checkModule = checkModulePermissions();
112 // Admin module should be accessable by guests to login
113 if ((getModule() == 'admin') && ($checkModule == 'admin_only')) {
114 // This is fine and can be ignored
115 } elseif ($checkModule != 'done') {
117 logDebugMessage(__FILE__, __LINE__, sprintf("Check of module %s results in unexpected value: %s",
124 addFatalMessage(__FILE__, __LINE__, '{--WRONG_DB_SELECTED--}');
127 // No link to database!
128 addFatalMessage(__FILE__, __LINE__, '{--NO_DB_LINK--}');
131 // Maybe you forgot to enter your MySQL data?
132 addFatalMessage(__FILE__, __LINE__, '{--MYSQL_DATA_MISSING--}');
135 // Default output is 'direct' for HTML output
136 setConfigEntry('OUTPUT_MODE', 'direct');
138 // This hack prevents a backtrace in CSS output
139 if (isCssOutputMode()) {
140 // Problem with config so set output mode
141 setConfigEntry('OUTPUT_MODE', 'render');
144 // CFG: DATABASE-TYPE
145 setConfigEntry('_DB_TYPE', 'mysql3');
148 foreach (array('db/lib','databases','session','versions','install-functions','load_config','load_cache') as $inc) {
150 loadIncludeOnce('inc/' . $inc . '.php');
153 // Check wether we are in installation routine
154 if ((!isInstalling()) && (!isCssOutputMode()) && (!isRawOutputMode())) {
155 // Redirect to the URL
156 redirectToUrl('install.php');
160 // Handle fatal errors
161 runFilterChain('handle_fatal_errors');