]> git.mxchange.org Git - mailer.git/blob - inc/install/install_page_finalize.php
da7993effbff54130a10ada5270e0a82c72309a9
[mailer.git] / inc / install / install_page_finalize.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 10/02/2012 *
4  * ===================                          Last change: 10/02/2012 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : install-page_finalize.php                        *
8  * -------------------------------------------------------------------- *
9  * Short description : Installation page include file                   *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Include-Datei fuer Installationsseite            *
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 - 2012 by Mailer Developer Team                   *
20  * For more information visit: http://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')) || (!isInstallationPhase())) {
40         die();
41 } // END - if
42
43 // Check pre-conditions
44 if ((isPostRequestElementSet('finalize')) && (!isInstalled())) {
45         // You have submitted data then we have to reset the SQLs
46         initSqls();
47
48         // Connect to database server
49         SQL_CONNECT($GLOBALS['install_mysql']['host'], $GLOBALS['install_mysql']['login'], $GLOBALS['install_mysql']['pass1'], __FILE__, __LINE__);
50
51         // Is the link up?
52         if (SQL_IS_LINK_UP()) {
53                 // Seems to work, also right database?
54                 if (SQL_SELECT_DB($GLOBALS['install_mysql']['dbase'], __FILE__, __LINE__) === TRUE) {
55                         // Check for dumps
56                         if ((!isFileReadable(postRequestElement('spath') . 'install/tables.sql')) || (!isFileReadable(postRequestElement('spath') . 'install/menu-'.getLanguage().'.sql'))) {
57                                 // Installation area not found
58                                 reportBug(__FILE__, __LINE__, 'SQL dumps not found. Please extract ALL files from the archive or checkout all files out from SVN.');
59                                 return;
60                         } // END - if
61
62                         // Any errors detected?
63                         if (!ifFatalErrorsDetected()) {
64                                 // Set type, prefix from POST data and database name for later queries
65                                 setConfigEntry('_TABLE_TYPE'  , postRequestElement('mysql', 'type'));
66                                 setConfigEntry('_MYSQL_PREFIX', postRequestElement('mysql', 'prefix'));
67                                 setConfigEntry('__DB_NAME'    , $GLOBALS['install_mysql']['dbase']);
68
69                                 // Both exists so import them
70                                 foreach (array('tables', 'menu-'.getLanguage()) as $dump) {
71                                         // Should be save here because file_exists() is there but we check it again. :)
72                                         $FQFN = postRequestElement('spath') . 'install/' . $dump . '.sql';
73
74                                         // Is the file readable?
75                                         if (isFileReadable($FQFN)) {
76                                                 // Read the file
77                                                 $fileContent = readSqlDump($FQFN);
78
79                                                 // Split it up against ";\n" and merge it into existing SQLs
80                                                 mergeSqls(explode(";\n", $fileContent), 'install');
81                                         } else {
82                                                 // Not readable!
83                                                 reportBug(__FILE__, __LINE__, sprintf("SQL dump %s is not readable.", $dump));
84                                         }
85                                 } // END - foreach
86                                 //* DEBUG: */ die(__FUNCTION__.'['.__LINE__.']:'<pre>'.print_r(getSqls(), TRUE).'</pre>');
87
88                                 // Are some SQLs found?
89                                 if (countSqls() == 0) {
90                                         // Abort here
91                                         addFatalMessage(__FILE__, __LINE__, '{--INSTALLER_SQL_IMPORT_FAILED--}');
92                                         return;
93                                 } // END - if
94
95                                 // Now run all queries through
96                                 runFilterChain('run_sqls');
97
98                                 // Copy the config template and verify it
99                                 doInstallWriteLocalConfigurationFile(postRequestElement('spath'));
100                         } // END - if
101                 } // END - if
102         } // END - if
103
104         // Are some fatal errors there?
105         if (ifFatalErrorsDetected()) {
106                 $OUT = '';
107                 foreach (getFatalArray() as $value) {
108                         $OUT .= '    <li>' . $value . '</li>';
109                 } // END foreach
110                 $content['fatal_errors'] = $OUT;
111                 $OUT = '';
112                 foreach ($GLOBALS['install_mysql'] as $key => $value) {
113                         $OUT .= '    <input type="hidden" name="mysql[' . $key . ']" value="' . $value . '" />';
114                 } // END foreach
115                 $content['mysql_hidden'] = $OUT;
116                 $content['spath']      = postRequestElement('spath');
117                 $content['burl']       = postRequestElement('burl');
118                 $content['title']      = postRequestElement('title');
119                 $content['smtp_host']  = postRequestElement('smtp_host');
120                 $content['smtp_user']  = postRequestElement('smtp_user');
121                 $content['smtp_pass']  = postRequestElement('smtp_pass1');
122
123                 // Load template
124                 addTemplateToInstallContent('install_fatal_errors', $content);
125
126                 // We have handled all fatal errors here
127                 initFatalMessages();
128         } else {
129                 // Register ext-sql_patches and ext-task
130                 if ((registerExtension('sql_patches', NULL)) && (registerExtension('task', NULL))) {
131                         // Installation is done!
132                         redirectToUrl('install.php?install_page=finished');
133                 } else {
134                         // Something goes wrong on registration of ext-sql_patches
135                         addFatalMessage(__FILE__, __LINE__, '{--INSTALLER_FINALIZER_CANNOT_REGISTER_SQL_PATCHES--}');
136                 }
137         }
138 } else {
139         // Something goes wrong during installation! :-(
140         addFatalMessage(__FILE__, __LINE__, '{--INSTALLER_FINALIZER_FAILED--}');
141 }
142
143 // [EOF]
144 ?>