Fix for missing array elements
[mailer.git] / inc / install-inc.php
index 83571f7..38e4a6b 100644 (file)
@@ -47,10 +47,10 @@ if (!defined('__SECURITY')) {
 } // END - if
 
 // Init variables
-$mysql = array();
+$GLOBALS['install_mysql'] = array();
 if ((isPostRequestParameterSet('mysql')) && (is_array(postRequestParameter('mysql')))) {
        // Transfer 'mysql' array
-       $mysql = postRequestParameter('mysql');
+       $GLOBALS['install_mysql'] = postRequestParameter('mysql');
 } // END - if
 
 // Check if both passwords from SMTP are matching
@@ -95,23 +95,23 @@ if ((!isInstalled()) || (!isAdminRegistered())) {
                        break;
 
                case '2': // MySQL data (alone!)
-                       if (empty($mysql['dbase']))  $mysql['dbase']  = 'your_database';
-                       if (empty($mysql['login']))  $mysql['login']  = 'your_login';
-                       if (empty($mysql['host']))   $mysql['host']   = 'localhost';
-                       if (empty($mysql['prefix'])) $mysql['prefix'] = 'mxchange';
-                       if (empty($mysql['type']))   $mysql['type']   = 'MyISAM';
+                       if (empty($GLOBALS['install_mysql']['dbase']))  $GLOBALS['install_mysql']['dbase']  = 'your_database';
+                       if (empty($GLOBALS['install_mysql']['login']))  $GLOBALS['install_mysql']['login']  = 'your_login';
+                       if (empty($GLOBALS['install_mysql']['host']))   $GLOBALS['install_mysql']['host']   = 'localhost';
+                       if (empty($GLOBALS['install_mysql']['prefix'])) $GLOBALS['install_mysql']['prefix'] = 'mxchange';
+                       if (empty($GLOBALS['install_mysql']['type']))   $GLOBALS['install_mysql']['type']   = 'MyISAM';
                        if (ifFatalErrorsDetected()) {
                                addToInstallContent('<div class="install_fatal">');
                                foreach (getFatalArray() as $key => $err) {
                                        addToInstallContent('<div class="para"><strong>&middot;</strong>&nbsp;{--FATAL_NO--}' . ($key + 1) . ':&nbsp;' . $err . '</div>');
-                               }
+                               } // END - foreach
                                addToInstallContent('</div>');
-                       }
-                       $content['mysql_host']   = $mysql['host'];
-                       $content['mysql_dbase']  = $mysql['dbase'];
-                       $content['mysql_prefix'] = $mysql['prefix'];
-                       $content['mysql_login']  = $mysql['login'];
-                       $content['table_type']   = $mysql['type'];
+                       } // END - if
+                       $content['mysql_host']   = $GLOBALS['install_mysql']['host'];
+                       $content['mysql_dbase']  = $GLOBALS['install_mysql']['dbase'];
+                       $content['mysql_prefix'] = $GLOBALS['install_mysql']['prefix'];
+                       $content['mysql_login']  = $GLOBALS['install_mysql']['login'];
+                       $content['table_type']   = $GLOBALS['install_mysql']['type'];
                        $content['spath']        = postRequestParameter('spath');
                        $content['burl']         = postRequestParameter('burl');
                        $content['title']        = postRequestParameter('title');
@@ -145,13 +145,13 @@ if ((!isInstalled()) || (!isAdminRegistered())) {
                        } // END - if
 
                        // MySQL settings
-                       $content['mysql_host']   = $mysql['host'];
-                       $content['mysql_dbase']  = $mysql['dbase'];
-                       $content['mysql_prefix'] = $mysql['prefix'];
-                       $content['table_type']   = $mysql['type'];
-                       $content['mysql_login']  = $mysql['login'];
-                       $content['mysql_pass1']  = $mysql['pass1'];
-                       $content['mysql_pass2']  = $mysql['pass2'];
+                       $content['mysql_host']   = $GLOBALS['install_mysql']['host'];
+                       $content['mysql_dbase']  = $GLOBALS['install_mysql']['dbase'];
+                       $content['mysql_prefix'] = $GLOBALS['install_mysql']['prefix'];
+                       $content['table_type']   = $GLOBALS['install_mysql']['type'];
+                       $content['mysql_login']  = $GLOBALS['install_mysql']['login'];
+                       $content['mysql_pass1']  = $GLOBALS['install_mysql']['pass1'];
+                       $content['mysql_pass2']  = $GLOBALS['install_mysql']['pass2'];
 
                        // Set constants for SMTP data
                        $content['smtp_host']  = $smtpHost;
@@ -178,7 +178,7 @@ if ((!isInstalled()) || (!isAdminRegistered())) {
 
                        // MySQL data
                        $OUT = '';
-                       foreach ($mysql as $key => $value) {
+                       foreach ($GLOBALS['install_mysql'] as $key => $value) {
                                $OUT .= "    <input type=\"hidden\" name=\"mysql[" . $key . "]\" value=\"" . $value . "\" />\n";
                        } // END - foreach
                        $content['mysql_hidden'] = $OUT;
@@ -193,16 +193,20 @@ if ((!isInstalled()) || (!isAdminRegistered())) {
                                initSqls();
 
                                // Connect to MySQL server
-                               SQL_CONNECT($mysql['host'], $mysql['login'], $mysql['pass1'], __FILE__, __LINE__);
+                               SQL_CONNECT($GLOBALS['install_mysql']['host'], $GLOBALS['install_mysql']['login'], $GLOBALS['install_mysql']['pass1'], __FILE__, __LINE__);
+
+                               // Is the link up?
                                if (SQL_IS_LINK_UP()) {
                                        // Seems to work, also right database?
-                                       if (SQL_SELECT_DB($mysql['dbase'], __FILE__, __LINE__) === true) {
-                                               // Automatically run install.sql
+                                       if (SQL_SELECT_DB($GLOBALS['install_mysql']['dbase'], __FILE__, __LINE__) === true) {
+                                               // Check for dumps
                                                if ((!isFileReadable(postRequestParameter('spath') . 'install/tables.sql')) || (!isFileReadable(postRequestParameter('spath') . 'install/menu-'.getLanguage().'.sql'))) {
                                                        // Installation area not found!
                                                        addFatalMessage(__FILE__, __LINE__, getMessage('INSTALL_MISSING_DUMPS'));
+                                                       return;
                                                } // END - if
 
+                                               // Any errors detected?
                                                if (!ifFatalErrorsDetected()) {
                                                        // Set type and prefix from POST data
                                                        setConfigEntry('_TABLE_TYPE'  , postRequestParameter('mysql', 'type'));
@@ -225,7 +229,7 @@ if ((!isInstalled()) || (!isAdminRegistered())) {
                                                                        debug_report_bug(sprintf("SQL dump %s is not readable!", $dump));
                                                                }
                                                        } // END - foreach
-                                                       //* DEBUG: */ die('<pre>'.print_r(getSqls(), true).'</pre>');
+                                                       //* DEBUG: */ die(__FUNCTION__.'['.__LINE__.']:'<pre>'.print_r(getSqls(), true).'</pre>');
 
                                                        // Are some SQLs found?
                                                        if (countSqls() == 0) {
@@ -250,7 +254,7 @@ if ((!isInstalled()) || (!isAdminRegistered())) {
                                        } // END foreach
                                        $content['fatal_errors'] = $OUT;
                                        $OUT = '';
-                                       foreach ($mysql as $key => $value) {
+                                       foreach ($GLOBALS['install_mysql'] as $key => $value) {
                                                $OUT .= '    <input type="hidden" name="mysql[' . $key . ']" value="' . $value . '" />';
                                        } // END foreach
                                        $content['mysql_hidden'] = $OUT;