]> git.mxchange.org Git - mailer.git/blob - inc/mysql-connect.php
Missing variable fixed, array initialization moved
[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  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * -------------------------------------------------------------------- *
18  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
19  * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
20  * For more information visit: http://www.mxchange.org                  *
21  *                                                                      *
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.                                  *
26  *                                                                      *
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.                         *
31  *                                                                      *
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,               *
35  * MA  02110-1301  USA                                                  *
36  ************************************************************************/
37
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
40         die();
41 } // END - if
42
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');
47 } // END - foreach
48
49 // Set error handler
50 set_error_handler('__errorHandler');
51
52 // Disable block-mode by default
53 enableBlockMode(false);
54
55 // Init error handler
56 initErrorHandler();
57
58 // Init request
59 initRequest();
60
61 // Init userid
62 initMemberId();
63
64 // Set important header_sent
65 if (!isset($GLOBALS['header_sent'])) {
66         $GLOBALS['header_sent'] = '0';
67 } // END - if
68
69 // Init fatal messages
70 initFatalMessages();
71
72 // Init repository data sub-system
73 initRepositoryData();
74
75 // Enable HTML templates by default
76 enableTemplateHtml();
77
78 // Are we in installation phase?
79 if ((!isInstalling()) && (!isInstallationPhase())) {
80         // Load configuration file(s) here
81         loadIncludeOnce('inc/load_config.php');
82
83         // Load database layer here
84         loadIncludeOnce('inc/db/lib.php');
85
86         // Init message system
87         initMessages();
88
89         // CSS array
90         initExtensionCssFiles();
91
92         if ((!empty($GLOBALS['mysql']['host'])) && (!empty($GLOBALS['mysql']['login'])) && (!empty($GLOBALS['mysql']['dbase']))) {
93                 // Connect to DB
94                 SQL_CONNECT($GLOBALS['mysql']['host'], $GLOBALS['mysql']['login'], $GLOBALS['mysql']['password'], __FILE__, __LINE__);
95
96                 // Is the link valid?
97                 if (SQL_IS_LINK_UP()) {
98                         // Enable exit on error
99                         enableExitOnError();
100
101                         // Is it a valid resource?
102                         if (SQL_SELECT_DB($GLOBALS['mysql']['dbase'], __FILE__, __LINE__) === true) {
103                                 // This is required for extension 'optimize' to work
104                                 setConfigEntry('__DB_NAME', $GLOBALS['mysql']['dbase']);
105
106                                 // Remove MySQL array from namespace
107                                 unset($GLOBALS['mysql']);
108
109                                 // Load cache
110                                 loadIncludeOnce('inc/load_cache.php');
111                         } else {
112                                 // Wrong database?
113                                 addFatalMessage(__FILE__, __LINE__, '{--WRONG_DB_SELECTED--}');
114                         }
115                 } else {
116                         // No link to database!
117                         addFatalMessage(__FILE__, __LINE__, '{--NO_DB_LINK--}');
118                 }
119         } else {
120                 // Maybe you forgot to enter your database login?
121                 addFatalMessage(__FILE__, __LINE__, '{--MYSQL_DATA_MISSING--}');
122         }
123 } else {
124         // Default output is 'direct' for HTML output
125         setConfigEntry('OUTPUT_MODE', 'direct');
126
127         // This hack prevents a backtrace in CSS output
128         if (isCssOutputMode()) {
129                 // Problem with config so set output mode
130                 setConfigEntry('OUTPUT_MODE', 'render');
131         } // END - if
132
133         // CFG: DATABASE-TYPE
134         setConfigEntry('_DB_TYPE', 'mysql3');
135
136         // Load database layer here
137         loadIncludeOnce('inc/db/lib.php');
138
139         // Init message system
140         initMessages();
141
142         // Include more
143         foreach (array('databases', 'session', 'versions', 'install-functions', 'load_config', 'load_cache') as $inc) {
144                 // Load the include
145                 loadIncludeOnce('inc/' . $inc . '.php');
146         } // END - foreach
147
148         // Check wether we are in installation routine
149         if ((!isInstalling()) && (!isCssOutputMode()) && (!isRawOutputMode())) {
150                 // Redirect to the URL
151                 redirectToUrl('install.php');
152         } // END - if
153 }
154
155 // Handle fatal errors
156 runFilterChain('handle_fatal_errors');
157
158 // [EOF]
159 ?>