Prefix in install script is the same as in runtime scripts
[mailer.git] / inc / install-inc.php
index 89e03018886ec9ca54889b54f44dccec34e86c09..7312a401f0d158b32cc1d9f13280d854d08b9738 100644 (file)
  * -------------------------------------------------------------------- *
  * Kurzbeschreibung  : Funktionen fuer die Installationsroutine         *
  * -------------------------------------------------------------------- *
- *                                                                      *
+ * $Revision::                                                        $ *
+ * $Date::                                                            $ *
+ * $Tag:: 0.2.1-FINAL                                                 $ *
+ * $Author::                                                          $ *
+ * Needs to be in all Files and every File needs "svn propset           *
+ * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
  * For more information visit: http://www.mxchange.org                  *
@@ -41,11 +46,8 @@ if (!defined('__SECURITY')) {
        require($INC);
 }
 
-// Load sql_patches here
-LOAD_EXTENSION("sql_patches");
-
 // Init variables
-$mysql = "";
+$mysql = array();
 if ((REQUEST_ISSET_POST(('mysql'))) && (is_array(REQUEST_POST('mysql')))) $mysql = REQUEST_POST('mysql');
 
 // Check if both passwords from SMTP are matching
@@ -99,7 +101,8 @@ if ((!isInstalled()) || (!isAdminRegistered()))
                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['prefix'])) $mysql['prefix'] = "mxchange";
+               if (empty($mysql['type']))   $mysql['type']   = "MyISAM";
                if (getTotalFatalErrors() > 0) {
                        OUTPUT_HTML("<span class=\"install_fatal\">");
                        foreach (getFatalArray() as $key => $err) {
@@ -110,6 +113,7 @@ if ((!isInstalled()) || (!isAdminRegistered()))
                define('__MYSQL_HOST'  , $mysql['host']);
                define('__MYSQL_DBASE' , $mysql['dbase']);
                define('__MYSQL_PREFIX', $mysql['prefix']);
+               define('__TABLE_TYPE'  , $mysql['type']);
                define('__MYSQL_LOGIN' , $mysql['login']);
                define('__SPATH_VALUE' , REQUEST_POST('spath'));
                define('__BURL_VALUE'  , REQUEST_POST('burl'));
@@ -143,6 +147,7 @@ if ((!isInstalled()) || (!isAdminRegistered()))
                define('__MYSQL_HOST'   , $mysql['host']);
                define('__MYSQL_DBASE'  , $mysql['dbase']);
                define('__MYSQL_PREFIX' , $mysql['prefix']);
+               define('__TABLE_TYPE'   , $mysql['type']);
                define('__MYSQL_LOGIN'  , $mysql['login']);
                define('__MYSQL_PASS1'  , $mysql['pass1']);
                define('__MYSQL_PASS2'  , $mysql['pass2']);
@@ -169,6 +174,7 @@ if ((!isInstalled()) || (!isAdminRegistered()))
                define('__MYSQL_HOST'   , $mysql['host']);
                define('__MYSQL_DBASE'  , $mysql['dbase']);
                define('__MYSQL_PREFIX' , $mysql['prefix']);
+               define('__TABLE_TYPE'   , $mysql['type']);
                define('__MYSQL_LOGIN'  , $mysql['login']);
 
                // SMTP settings
@@ -248,9 +254,9 @@ if ((!isInstalled()) || (!isAdminRegistered()))
 <tr>
   <td colspan=\"2\" align=\"center\">");
                foreach ($mysql as $key => $value) {
-                       OUTPUT_HTML("    <input type=\"hidden\" name=\"mysql[".$key."]\" value=\"".$value."\">");
+                       OUTPUT_HTML("    <input type=\"hidden\" name=\"mysql[".$key."]\" value=\"".$value."\" />");
                }
-               OUTPUT_HTML("    <input type=\"hidden\" name=\"spath\" value=\"{!__SPATH_VALUE!}\">
+               OUTPUT_HTML("    <input type=\"hidden\" name=\"spath\" value=\"{!__SPATH_VALUE!}\" />
     <input type=\"hidden\" name=\"burl\" value=\"{!__BURL_VALUE!}\" />
     <input type=\"hidden\" name=\"title\" value=\"{!__TITLE_VALUE!}\" />
     <input type=\"hidden\" name=\"slogan\" value=\"{!__SLOGAN_VALUE!}\" />
@@ -268,7 +274,7 @@ if ((!isInstalled()) || (!isAdminRegistered()))
 
        case "finalize": // Write captured data to files
                if ((REQUEST_ISSET_POST(('finalize'))) && (!isInstalled())) {
-                       // You have submitted data then we have to reset the fatal messages
+                       // You have submitted data then we have to reset the SQLs
                        INIT_SQLS();
 
                        // Connect to MySQL server
@@ -279,9 +285,9 @@ if ((!isInstalled()) || (!isAdminRegistered()))
                                        // Automatically run install.sql
                                        if ((FILE_READABLE(REQUEST_POST('spath')."install/tables.sql")) && (FILE_READABLE(REQUEST_POST('spath')."install/menu-".GET_LANGUAGE().".sql"))) {
                                                // Both exists so import them
-                                               foreach (array("tables.sql", "menu-".GET_LANGUAGE().".sql") as $dump) {
+                                               foreach (array("tables", "menu-".GET_LANGUAGE()) as $dump) {
                                                        // Should be save here because file_exists() is there but we check it again. :)
-                                                       $FQFN = secureString(REQUEST_POST('spath')) . "install/" . $dump;
+                                                       $FQFN = REQUEST_POST('spath') . "install/" . $dump . ".sql";
                                                        if (FILE_READABLE($FQFN)) {
                                                                // Read the file
                                                                $fileContent = READ_FILE($FQFN, true);
@@ -291,6 +297,11 @@ if ((!isInstalled()) || (!isAdminRegistered()))
                                                                        $fileContent = str_replace("{!prefix!}", $mysql['prefix'], $fileContent);
                                                                } // END - while
 
+                                                               // Replace the {!type!} with actual one
+                                                               while (strpos($fileContent, "{!type!}") !== false) {
+                                                                       $fileContent = str_replace("{!type!}", $mysql['type'], $fileContent);
+                                                               } // END - while
+
                                                                // And split it up against ;\n ...
                                                                SET_SQLS(merge_array(GET_SQLS(), explode(";\n", $fileContent)));
                                                        } else {
@@ -324,6 +335,7 @@ if ((!isInstalled()) || (!isAdminRegistered()))
                                                changeDataInFile(REQUEST_POST('spath')."inc/config.php", "MYSQL-LOGIN", "       'login'    => \"", "\",", $mysql['login'], 0);
                                                changeDataInFile(REQUEST_POST('spath')."inc/config.php", "MYSQL-PASSWORD", "    'password' => \"", "\",", $mysql['pass1'], 0);
                                                changeDataInFile(REQUEST_POST('spath')."inc/config.php", "MYSQL-PREFIX", "define('_MYSQL_PREFIX', \"", "\");", $mysql['prefix'], 0);
+                                               changeDataInFile(REQUEST_POST('spath')."inc/config.php", "TABLE-TYPE", "define('_TABLE_TYPE', \"", "\");", $mysql['type'], 0);
                                                changeDataInFile(REQUEST_POST('spath')."inc/config.php", "SMTP-HOSTNAME", "define('SMTP_HOSTNAME', \"", "\");", REQUEST_POST('smtp_host'), 0);
                                                changeDataInFile(REQUEST_POST('spath')."inc/config.php", "SMTP-USER", "define('SMTP_USER', \"", "\");", REQUEST_POST('smtp_user'), 0);
                                                changeDataInFile(REQUEST_POST('spath')."inc/config.php", "SMTP-PASSWORD", "define('SMTP_PASSWORD', \"", "\");", REQUEST_POST('smtp_pass1'), 0);