]> git.mxchange.org Git - mailer.git/blobdiff - inc/install-inc.php
HTML fixes and rewritten install finalizer
[mailer.git] / inc / install-inc.php
index 1631b93f876f8ebd40a986a44e34684ad3a2de38..91eab08c8bcb1b4d4e1a97b9d5c1d066a9967000 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                  *
 
 // Some security stuff...
 if (!defined('__SECURITY')) {
-       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
+       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
        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
-if ((REQUEST_ISSET_GET(('page')) && (REQUEST_GET('page') == 5))) {
+if ((REQUEST_ISSET_GET('page') && (REQUEST_GET('page') == 5))) {
        // Okay, we have to check it
        if (REQUEST_ISSET_POST(('smtp_user')) && (!REQUEST_ISSET_POST(('smtp_host')))) {
                // Hostname not set
@@ -99,7 +101,7 @@ 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\">");
@@ -180,7 +182,7 @@ if ((!isInstalled()) || (!isAdminRegistered()))
                define('__SMTP_USER'    , REQUEST_POST('smtp_user'));
                define('__SMTP_PASS'    , REQUEST_POST('smtp_pass1'));
                OUTPUT_HTML("<form action=\"{!__BURL_ACTION!}/install.php?page=finalize\" method=\"POST\" target=\"_self\">
-<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"install_content\">
+<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"install_main\">
 <tr>
   <td colspan=\"2\" align=\"center\">
     <div class=\"install\">{--HEADER_TEXT_PAGE5--}</strong>
@@ -188,7 +190,7 @@ if ((!isInstalled()) || (!isAdminRegistered()))
 </tr>
 <tr><td colspan=\"2\" height=\"21\" class=\"seperator\">&nbsp;</td></tr>
 <tr>
-  <td colspan=\"2\"><span class=\"install_intro\">
+  <td colspan=\"2\"><span class=\"install_text\">
     {--TEXT_PAGE_5--}
   </span></td>
 </tr>
@@ -198,10 +200,10 @@ if ((!isInstalled()) || (!isAdminRegistered()))
   <td>
     <select name=\"omode\" size=\"1\" class=\"install_select\">
       <option value=\"render\"");
-               if (constant('OUTPUT_MODE') == "render") OUTPUT_HTML(" selected=\"selected\"");
+               if (constant('OUTPUT_MODE') == "render") OUTPUT_HTML(' selected="selected"');
                OUTPUT_HTML(">{--MODE_RENDER--}</option>
       <option value=\"direct\"");
-               if (constant('OUTPUT_MODE') == "direct") OUTPUT_HTML(" selected=\"selected\"");
+               if (constant('OUTPUT_MODE') == "direct") OUTPUT_HTML(' selected="selected"');
                OUTPUT_HTML(">{--MODE_DIRECT--}</option>
     </select>
   </td>
@@ -212,10 +214,10 @@ if ((!isInstalled()) || (!isAdminRegistered()))
   <td>
     <select name=\"warn_no_pass\" size=\"1\" class=\"install_select\">
       <option value=\"true\"");
-               if (isBooleanConstantAndTrue('warn_no_pass')) OUTPUT_HTML(" selected=\"selected\"");
+               if (isBooleanConstantAndTrue('warn_no_pass')) OUTPUT_HTML(' selected="selected"');
                OUTPUT_HTML(">{--YES--}</option>
       <option value=\"false\"");
-               if (!isBooleanConstantAndTrue('warn_no_pass')) OUTPUT_HTML(" selected=\"selected\"");
+               if (!isBooleanConstantAndTrue('warn_no_pass')) OUTPUT_HTML(' selected="selected"');
                OUTPUT_HTML(">{--NO--}</option>
     </select>
   </td>
@@ -226,10 +228,10 @@ if ((!isInstalled()) || (!isAdminRegistered()))
   <td>
     <select name=\"wfooter\" size=\"1\" class=\"install_select\">
       <option value=\"true\"");
-               if (isBooleanConstantAndTrue('WRITE_FOOTER')) OUTPUT_HTML(" selected=\"selected\"");
+               if (isBooleanConstantAndTrue('WRITE_FOOTER')) OUTPUT_HTML(' selected="selected"');
                OUTPUT_HTML(">{--YES--}</option>
       <option value=\"false\"");
-               if (!isBooleanConstantAndTrue('WRITE_FOOTER')) OUTPUT_HTML(" selected=\"selected\"");
+               if (!isBooleanConstantAndTrue('WRITE_FOOTER')) OUTPUT_HTML(' selected="selected"');
                OUTPUT_HTML(">{--NO--}</option>
     </select>
   </td>
@@ -240,10 +242,10 @@ if ((!isInstalled()) || (!isAdminRegistered()))
   <td>
     <select name=\"blink\" size=\"1\" class=\"install_select\">
       <option value=\"true\"");
-               if (isBooleanConstantAndTrue('ENABLE_BACKLINK')) OUTPUT_HTML(" selected=\"selected\"");
+               if (isBooleanConstantAndTrue('ENABLE_BACKLINK')) OUTPUT_HTML(' selected="selected"');
                OUTPUT_HTML(">{--YES--}</option>
       <option value=\"false\"");
-               if (!isBooleanConstantAndTrue('ENABLE_BACKLINK')) OUTPUT_HTML(" selected=\"selected\"");
+               if (!isBooleanConstantAndTrue('ENABLE_BACKLINK')) OUTPUT_HTML(' selected="selected"');
                OUTPUT_HTML(">{--NO--}</option>
     </select>
   </td>
@@ -281,24 +283,23 @@ if ((!isInstalled()) || (!isAdminRegistered()))
                                // Seems to work, also right database?
                                if (SQL_SELECT_DB($mysql['dbase'], __FILE__, __LINE__) === true) {
                                        // Automatically run install.sql
-                                       if ((FILE_READABLE(REQUEST_POST('spath')."install/tables.sql")) && (FILE_READABLE(REQUEST_POST('spath')."install/menu-".GET_LANGUAGE().".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", "menu-".GET_LANGUAGE()) 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 = REQUEST_POST('spath') . "install/" . $dump . ".sql";
+                                                       $FQFN = REQUEST_POST('spath') . 'install/' . $dump . '.sql';
+
+                                                       // Is the file readable?
                                                        if (FILE_READABLE($FQFN)) {
                                                                // Read the file
                                                                $fileContent = READ_FILE($FQFN, true);
 
-                                                               // Replace the {!prefix!} with actual one
-                                                               while (strpos($fileContent, "{!prefix!}") !== false) {
-                                                                       $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
+                                                               // Replace the {!prefix/type!} with actual one
+                                                               foreach (array('prefix', 'type') as $replace) {
+                                                                       while (strpos($fileContent, '{!' . $replace . '!}') !== false) {
+                                                                               $fileContent = str_replace('{!' . $replace . '!}', $mysql[$replace], $fileContent);
+                                                                       } // END - while
+                                                               } // END - foreach
 
                                                                // And split it up against ;\n ...
                                                                SET_SQLS(merge_array(GET_SQLS(), explode(";\n", $fileContent)));
@@ -346,14 +347,14 @@ if ((!isInstalled()) || (!isAdminRegistered()))
                        } // END - if
 
                        if (getTotalFatalErrors() > 0) {
-                               $OUT = "";
+                               $OUT = '';
                                foreach (getFatalArray() as $value) {
                                        $OUT .= "    <li>".$value."</li>\n";
                                } // END foreach
                                define('__FATAL_ERROR_LI', $OUT);
-                               $OUT = "";
+                               $OUT = '';
                                foreach ($mysql as $key => $value) {
-                                       $OUT .= "    <input type=\"hidden\" name=\"mysql[".$key."]\" value=\"".$value."\">\n";
+                                       $OUT .= "    <input type=\"hidden\" name=\"mysql[".$key."]\" value=\"".$value."\" />\n";
                                } // END foreach
                                define('__MYSQL_DATA'   , $OUT);
                                define('__SPATH_VALUE'  , REQUEST_POST('spath'));
@@ -364,24 +365,24 @@ if ((!isInstalled()) || (!isAdminRegistered()))
                                define('__SMTP_PASS'    , REQUEST_POST('smtp_pass1'));
 
                                // Load template
-                               LOAD_TEMPLATE("install_fatal_errors");
+                               LOAD_TEMPLATE('install_fatal_errors');
                        } else {
                                // Installation is done!
-                               LOAD_URL("install.php?page=finalize");
+                               LOAD_URL('install.php?page=finalize');
                        }
                } elseif (isInstalled()) {
                        // Redirection after writing data... :-)
-                       LOAD_TEMPLATE("install_finished");
+                       LOAD_TEMPLATE('install_finished');
                } else {
                        // Something goes wrong during installation! :-(
                        addFatalMessage(__FILE__, __LINE__, getMessage('INSTALL_FINALIZER_FAILED'));
-                       LOAD_INC("inc/fatal_errors.php");
+                       LOAD_INC('inc/fatal_errors.php');
                }
                break;
 
        default:
                DEBUG_LOG(__FILE__, __LINE__, sprintf("Wrong page %s detected", REQUEST_GET('page')));
-               OUTPUT_HTML("    <div class=\"install_error\">{--WRONG_PAGE--}</strong>");
+               OUTPUT_HTML("    <div class=\"install_error\">{--WRONG_PAGE--}</div>");
                break;
        }
 } else {