]> git.mxchange.org Git - mailer.git/blob - inc/install/install_page_finalize.php
b8e2f287c4b210db747028aaee4c658049a3de73
[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         // Remove any existing "cache"
49         unset($GLOBALS['is_sql_link_up']);
50
51         // Connect to database server
52         SQL_CONNECT($GLOBALS['install_mysql']['host'], $GLOBALS['install_mysql']['login'], $GLOBALS['install_mysql']['pass1'], __FILE__, __LINE__);
53
54         // Is the link up?
55         if (SQL_IS_LINK_UP()) {
56                 // Seems to work, also right database?
57                 if (SQL_SELECT_DB($GLOBALS['install_mysql']['dbase'], __FILE__, __LINE__) === TRUE) {
58                         // Check for dumps
59                         if ((!isFileReadable(postRequestElement('spath') . 'install/tables.sql')) || (!isFileReadable(postRequestElement('spath') . 'install/menu-'.getLanguage().'.sql'))) {
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                                 // Both exists so import them
73                                 foreach (array('tables', 'menu-'.getLanguage()) as $dump) {
74                                         // Should be save here because file_exists() is there but we check it again. :)
75                                         $FQFN = postRequestElement('spath') . 'install/' . $dump . '.sql';
76
77                                         // Is the file readable?
78                                         if (isFileReadable($FQFN)) {
79                                                 // Read the file
80                                                 $fileContent = readSqlDump($FQFN);
81
82                                                 // Split it up against ";\n" and merge it into existing SQLs
83                                                 mergeSqls(explode(";\n", $fileContent), 'install');
84                                         } else {
85                                                 // Not readable!
86                                                 reportBug(__FILE__, __LINE__, sprintf("SQL dump %s is not readable.", $dump));
87                                         }
88                                 } // END - foreach
89                                 //* DEBUG: */ die(__FUNCTION__.'['.__LINE__.']:'<pre>'.print_r(getSqls(), TRUE).'</pre>');
90
91                                 // Are some SQLs found?
92                                 if (countSqls() == 0) {
93                                         // Abort here
94                                         addFatalMessage(__FILE__, __LINE__, '{--INSTALLER_SQL_IMPORT_FAILED--}');
95                                         return;
96                                 } // END - if
97
98                                 // Now run all queries through
99                                 runFilterChain('run_sqls');
100
101                                 // Copy the config template and verify it
102                                 doInstallWriteLocalConfigurationFile(postRequestElement('spath'));
103                         } // END - if
104                 } // END - if
105         } // END - if
106
107         // Are some fatal errors there?
108         if (ifFatalErrorsDetected()) {
109                 $OUT = '';
110                 foreach (getFatalArray() as $value) {
111                         $OUT .= '    <li>' . $value . '</li>';
112                 } // END foreach
113                 $content['fatal_errors'] = $OUT;
114                 $OUT = '';
115                 foreach ($GLOBALS['install_mysql'] as $key => $value) {
116                         $OUT .= '    <input type="hidden" name="mysql[' . $key . ']" value="' . $value . '" />';
117                 } // END foreach
118                 $content['mysql_hidden'] = $OUT;
119                 $content['spath']      = postRequestElement('spath');
120                 $content['burl']       = postRequestElement('burl');
121                 $content['title']      = postRequestElement('title');
122                 $content['smtp_host']  = postRequestElement('smtp_host');
123                 $content['smtp_user']  = postRequestElement('smtp_user');
124                 $content['smtp_pass']  = postRequestElement('smtp_pass1');
125
126                 // Load template
127                 addTemplateToInstallContent('install_fatal_errors', $content);
128
129                 // We have handled all fatal errors here
130                 initFatalMessages();
131         } else {
132                 // Register ext-sql_patches and ext-task
133                 if ((registerExtension('sql_patches', NULL)) && (registerExtension('task', NULL))) {
134                         // Installation is done!
135                         redirectToUrl('install.php?install_page=finished');
136                 } else {
137                         // Something goes wrong on registration of ext-sql_patches
138                         addFatalMessage(__FILE__, __LINE__, '{--INSTALLER_FINALIZER_CANNOT_REGISTER_SQL_PATCHES--}');
139                 }
140         }
141 } else {
142         // Something goes wrong during installation! :-(
143         addFatalMessage(__FILE__, __LINE__, '{--INSTALLER_FINALIZER_FAILED--}');
144 }
145
146 // [EOF]
147 ?>