2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 10/02/2012 *
4 * =================== Last change: 10/02/2012 *
6 * -------------------------------------------------------------------- *
7 * File : install-page_finalize.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Installation page include file *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Include-Datei fuer Installationsseite *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
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 *
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. *
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. *
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, *
36 ************************************************************************/
38 // Some security stuff...
39 if ((!defined('__SECURITY')) || (!isInstallationPhase())) {
43 // Check pre-conditions
44 if ((isPostRequestElementSet('finalize')) && (!isInstalled())) {
45 // You have submitted data then we have to reset the SQLs
49 * Restore PHPs error handler to prevent ours to handle errors,
50 * e.g. failed connection attempts. We want to handle them on
53 restore_error_handler();
55 // Connect to database server
56 SQL_CONNECT($GLOBALS['install_mysql']['host'], $GLOBALS['install_mysql']['login'], $GLOBALS['install_mysql']['pass1'], __FILE__, __LINE__);
59 if (SQL_IS_LINK_UP()) {
60 // Seems to work, also right database?
61 if (SQL_SELECT_DB($GLOBALS['install_mysql']['dbase'], __FILE__, __LINE__) === TRUE) {
63 if ((!isFileReadable(postRequestElement('spath') . 'install/tables.sql')) || (!isFileReadable(postRequestElement('spath') . 'install/menu-'.getLanguage().'.sql'))) {
64 // Installation area not found
65 reportBug(__FILE__, __LINE__, 'SQL dumps not found. Please extract ALL files from the archive or checkout all files out from SVN.');
69 // Any errors detected?
70 if (!ifFatalErrorsDetected()) {
71 // Set type, prefix from POST data and database name for later queries
72 setConfigEntry('_TABLE_TYPE' , postRequestElement('mysql', 'type'));
73 setConfigEntry('_MYSQL_PREFIX', postRequestElement('mysql', 'prefix'));
74 setConfigEntry('__DB_NAME' , $GLOBALS['install_mysql']['dbase']);
76 // Both exists so import them
77 foreach (array('tables', 'menu-'.getLanguage()) as $dump) {
78 // Should be save here because file_exists() is there but we check it again. :)
79 $FQFN = postRequestElement('spath') . 'install/' . $dump . '.sql';
81 // Is the file readable?
82 if (isFileReadable($FQFN)) {
84 $fileContent = readSqlDump($FQFN);
86 // Split it up against ";\n" and merge it into existing SQLs
87 mergeSqls(explode(";\n", $fileContent), 'install');
90 reportBug(__FILE__, __LINE__, sprintf("SQL dump %s is not readable.", $dump));
93 //* DEBUG: */ die(__FUNCTION__.'['.__LINE__.']:'<pre>'.print_r(getSqls(), TRUE).'</pre>');
95 // Are some SQLs found?
96 if (countSqls() == 0) {
98 addFatalMessage(__FILE__, __LINE__, '{--INSTALLER_SQL_IMPORT_FAILED--}');
102 // Now run all queries through
103 runFilterChain('run_sqls');
105 // Copy the config template and verify it
106 doInstallWriteLocalConfigurationFile(postRequestElement('spath'));
111 // Are some fatal errors there?
112 if (ifFatalErrorsDetected()) {
114 foreach (getFatalArray() as $value) {
115 $OUT .= ' <li>' . $value . '</li>';
117 $content['fatal_errors'] = $OUT;
119 foreach ($GLOBALS['install_mysql'] as $key => $value) {
120 $OUT .= ' <input type="hidden" name="mysql[' . $key . ']" value="' . $value . '" />';
122 $content['mysql_hidden'] = $OUT;
123 $content['spath'] = postRequestElement('spath');
124 $content['burl'] = postRequestElement('burl');
125 $content['title'] = postRequestElement('title');
126 $content['smtp_host'] = postRequestElement('smtp_host');
127 $content['smtp_user'] = postRequestElement('smtp_user');
128 $content['smtp_pass'] = postRequestElement('smtp_pass1');
131 addTemplateToInstallContent('install_fatal_errors', $content);
133 // We have handled all fatal errors here
136 // Register ext-sql_patches and ext-task
137 if ((registerExtension('sql_patches', NULL)) && (registerExtension('task', NULL))) {
138 // Installation is done!
139 redirectToUrl('install.php?install_page=finished');
141 // Something goes wrong on registration of ext-sql_patches
142 addFatalMessage(__FILE__, __LINE__, '{--INSTALLER_FINALIZER_CANNOT_REGISTER_SQL_PATCHES--}');
146 // Something goes wrong during installation! :-(
147 addFatalMessage(__FILE__, __LINE__, '{--INSTALLER_FINALIZER_FAILED--}');