]> git.mxchange.org Git - mailer.git/blobdiff - inc/mysql-connect.php
More globals rewritten, see #100
[mailer.git] / inc / mysql-connect.php
index fdc059a8fb27904640f3cce2499486a0081d2199..0d53569e82584100cf0b2705e8f5c45098af3adf 100644 (file)
@@ -83,14 +83,12 @@ set_error_handler('__errorHandler');
 
 // Call-back function for running shutdown functions and close database connection
 function __SHUTDOWN_HOOK () {
-       global $link;
-
        // Call the filter chain 'shutdown'
        RUN_FILTER('shutdown', null, false);
 
-       if (is_resource($link)) {
+       if (SQL_IS_LINK_UP()) {
                // Close link
-               SQL_CLOSE($link, __FILE__, __LINE__);
+               SQL_CLOSE(__FILE__, __LINE__);
        } else {
                // No database link
                addFatalMessage(getMessage('NO_DB_LINK'));
@@ -127,8 +125,7 @@ $_CONFIG = array(
 $GLOBALS['header_sent'] = 0;
 
 // Init fatal messages
-global $FATAL;
-$FATAL = array();
+initFatalMessages();
 
 // Check if this file is writeable or read-only and warn the user
 if ((!isBooleanConstantAndTrue('mxchange_installing')) && (isBooleanConstantAndTrue('mxchange_installed'))) {
@@ -136,21 +133,16 @@ if ((!isBooleanConstantAndTrue('mxchange_installing')) && (isBooleanConstantAndT
        if (empty($GLOBALS['module'])) $GLOBALS['module'] = "index";
 
        // CSS array
-       $EXT_CSS_FILES = array();
+       EXT_INIT_CSS_FILES();
 
        if ((!empty($MySQL['host'])) && (!empty($MySQL['login'])) && (!empty($MySQL['password'])) && (!empty($MySQL['dbase']))) {
                // Connect to DB
-               global $link;
-               $link = SQL_CONNECT($MySQL['host'], $MySQL['login'], $MySQL['password'], __FILE__, __LINE__);
+               SQL_CONNECT($MySQL['host'], $MySQL['login'], $MySQL['password'], __FILE__, __LINE__);
 
                // Is the link valid?
-               if (is_resource($link)) {
-                       // Choose the database
-                       global $db;
-                       $db = SQL_SELECT_DB($MySQL['dbase'], $link, __FILE__, __LINE__);
-
+               if (SQL_IS_LINK_UP()) {
                        // Is it a valid resource?
-                       if ($db === true) {
+                       if (SQL_SELECT_DB($MySQL['dbase'], __FILE__, __LINE__) === true) {
                                // This is required for extension 'optimize' to work
                                define('__DB_NAME', $MySQL['dbase']);
 
@@ -247,7 +239,6 @@ if ((!isBooleanConstantAndTrue('mxchange_installing')) && (isBooleanConstantAndT
 
                        // No link to database!
                        addFatalMessage(getMessage('NO_DB_LINK'));
-                       $db = false;
                }
        } else {
                // Add language system
@@ -263,7 +254,6 @@ if ((!isBooleanConstantAndTrue('mxchange_installing')) && (isBooleanConstantAndT
 
        // Set other missing variables
        if (!isset($GLOBALS['output_mode'])) $GLOBALS['output_mode'] = "0";
-       $link = false; // No database link by default
 
        // Include required files
        LOAD_INC_ONCE("inc/databases.php");