Added stuff for PHP extension selection in both installers.
[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 - 2013 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')) || (!isInstaller())) {
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         // Remove any existing "cache"
49         unsetSqlLinkUp(__FILE__, __LINE__);
50
51         // Connect to database server
52         sqlConnectToDatabase($GLOBALS['install_mysql']['host'], $GLOBALS['install_mysql']['login'], $GLOBALS['install_mysql']['password1'], __FILE__, __LINE__);
53
54         // Is the link up?
55         if (isSqlLinkUp()) {
56                 // Seems to work, also right database?
57                 if (sqlSelectDatabase($GLOBALS['install_mysql']['dbase'], __FILE__, __LINE__) === TRUE) {
58                         // Check for dumps
59                         if (!isInstallerSqlsReadable(postRequestElement('spath'))) {
60                                 // Installation area not found
61                                 reportBug(__FILE__, __LINE__, 'SQL dumps not found. Please extract ALL files from the archive or checkout all files out from SVN.');
62                                 return;
63                         } // END - if
64
65                         // Any errors detected?
66                         if (!ifFatalErrorsDetected()) {
67                                 // Set type, prefix from POST data and database name for later queries
68                                 setConfigEntry('_TABLE_TYPE'  , postRequestElement('mysql', 'type'));
69                                 setConfigEntry('_MYSQL_PREFIX', postRequestElement('mysql', 'prefix'));
70                                 setConfigEntry('__DB_NAME'    , $GLOBALS['install_mysql']['dbase']);
71
72                                 // Set path
73                                 setConfigEntry('PATH', postRequestElement('spath'));
74                                 unset($GLOBALS['getPath']);
75
76                                 // Both exists so import them
77                                 importInstallSqlDump('tables');
78                                 importInstallSqlDump('menu-' . getLanguage());
79                                 //* DEBUG: */ die(__FUNCTION__.'['.__LINE__.']:'<pre>'.print_r(getSqls(), TRUE).'</pre>');
80
81                                 // Are some SQLs found?
82                                 if (countSqls() == 0) {
83                                         // Abort here
84                                         addFatalMessage(__FILE__, __LINE__, '{--INSTALLER_SQL_IMPORT_FAILED--}');
85                                         return;
86                                 } // END - if
87
88                                 // Now run all queries through
89                                 runFilterChain('run_sqls');
90                         } // END - if
91                 } // END - if
92         } // END - if
93
94         // Are some fatal errors there?
95         if (ifFatalErrorsDetected()) {
96                 $OUT = '';
97                 foreach (getFatalArray() as $value) {
98                         $OUT .= '    <li>' . $value . '</li>';
99                 } // END foreach
100                 $content['fatal_errors'] = $OUT;
101                 $OUT = '';
102                 foreach ($GLOBALS['install_mysql'] as $key => $value) {
103                         $OUT .= '    <input type="hidden" name="mysql[' . $key . ']" value="' . $value . '" />';
104                 } // END foreach
105                 $content['mysql_hidden']  = $OUT;
106                 $content['spath']         = postRequestElement('spath');
107                 $content['burl']          = postRequestElement('burl');
108                 $content['title']         = postRequestElement('title');
109                 $content['slogan']        = postRequestElement('slogan');
110                 $content['email']         = postRequestElement('email');
111                 $content['smtp_host']     = postRequestElement('smtp_host');
112                 $content['smtp_user']     = postRequestElement('smtp_user');
113                 $content['smtp_password'] = postRequestElement('smtp_password1');
114
115                 // Load template
116                 addTemplateToInstallContent('install_fatal_errors', $content);
117
118                 // We have handled all fatal errors here
119                 initFatalMessages();
120         } else {
121                 // Copy the config template and verify it
122                 doInstallWriteLocalConfigurationFile(
123                         postRequestElement('spath'),
124                         postRequestElement('burl'),
125                         postRequestElement('title'),
126                         postRequestElement('slogan'),
127                         postRequestElement('email'),
128                         postRequestElement('warn_no_pass'),
129                         postRequestElement('wfooter'),
130                         postRequestElement('blink'),
131                         postRequestElement('mysql', 'host'),
132                         postRequestElement('mysql', 'dbase'),
133                         postRequestElement('mysql', 'login'),
134                         postRequestElement('mysql', 'password1'),
135                         postRequestElement('mysql', 'prefix'),
136                         postRequestElement('mysql', 'type'),
137                         postRequestElement('mysql', 'extension'),
138                         postRequestElement('smtp_host'),
139                         postRequestElement('smtp_user'),
140                         postRequestElement('smtp_password1')
141                 );
142
143                 // Register ext-sql_patches and ext-task
144                 if ((registerExtension('sql_patches', NULL)) && (registerExtension('task', NULL))) {
145                         // Installation is done!
146                         redirectToUrl('install.php?install_page=finished');
147                 } else {
148                         // Something goes wrong on registration of ext-sql_patches
149                         addFatalMessage(__FILE__, __LINE__, '{--INSTALLER_FINALIZER_CANNOT_REGISTER_SQL_PATCHES--}');
150                 }
151         }
152 } else {
153         // Something goes wrong during installation! :-(
154         addFatalMessage(__FILE__, __LINE__, '{--INSTALLER_FINALIZER_FAILED--}');
155 }
156
157 // [EOF]
158 ?>