handling of boolean constants improved (not fully)
[mailer.git] / inc / install-inc.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 08/29/2003 *
4  * ===============                              Last change: 11/11/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : install-inc.php                                  *
8  * -------------------------------------------------------------------- *
9  * Short description : Functions for installation procedure             *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Funktionen fuer die Installationsroutine         *
12  * -------------------------------------------------------------------- *
13  *                                                                      *
14  * -------------------------------------------------------------------- *
15  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
16  * For more information visit: http://www.mxchange.org                  *
17  *                                                                      *
18  * This program is free software; you can redistribute it and/or modify *
19  * it under the terms of the GNU General Public License as published by *
20  * the Free Software Foundation; either version 2 of the License, or    *
21  * (at your option) any later version.                                  *
22  *                                                                      *
23  * This program is distributed in the hope that it will be useful,      *
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
26  * GNU General Public License for more details.                         *
27  *                                                                      *
28  * You should have received a copy of the GNU General Public License    *
29  * along with this program; if not, write to the Free Software          *
30  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
31  * MA  02110-1301  USA                                                  *
32  ************************************************************************/
33
34 /************************************************************************
35  *      YOU MAY ALSO WANT TO REMOVE THIS FILE AFTER INSTALLTION!        *
36  ************************************************************************/
37
38 // Some security stuff...
39 if (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) {
40         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
41         require($INC);
42 }
43
44 //
45 function install_WriteData ($file, $comment, $prefix, $suffix, $DATA, $sneak=0) {
46         // Initialize all and count up the "seak" value
47         $done = false;
48         $next = 0;
49         $sneak++;
50         if ((file_exists($file)) && (is_readable($file))) {
51                 $search = "CFG: ".$comment;
52                 $tmp = $file.".tmp";
53                 $fp = @fopen($file, 'r') or OUTPUT_HTML("<STRONG>READ:</STRONG> ".$file."<br />");
54                 if (is_resource($fp)) {
55                         $fp_tmp = @fopen($tmp, 'w') or OUTPUT_HTML("<STRONG>WRITE:</STRONG> ".$tmp."<br />");
56                         if (is_resource($fp_tmp)) {
57                                 while (!feof($fp)) {
58                                         $line = fgets ($fp, 10240);
59                                         if (strpos($line, $search) > -1) $next = 0;
60                                         if ($next > -1) {
61                                                 if ($next == $sneak) {
62                                                         $next = -1;
63                                                         $line = $prefix.$DATA.$suffix."\n";
64                                                 } else {
65                                                         $next++;
66                                                 }
67                                         }
68                                         fputs($fp_tmp, $line);
69                                 }
70                                 fclose($fp_tmp);
71
72                                 // Finished writing tmp file
73                                 $done = true;
74                         }
75
76                         // Close source directory
77                         fclose($fp);
78
79                         if (($done) && (is_writeable($file))) {
80                                 // Copy back tmp file and delete tmp :-)
81                                 @copy($tmp, $file);
82                                 @unlink($tmp);
83                         } else {
84                                 OUTPUT_HTML("<STRONG>TMP:</STRONG> UNDONE!");
85                         }
86                 }
87         } else {
88                 OUTPUT_HTML("<STRONG>404:</STRONG> ".$file."<br />");
89         }
90 }
91
92 //
93 $mysql = "";
94 if (isset($_POST['mysql']) && is_array($_POST['mysql'])) $mysql = $_POST['mysql'];
95
96 if (URL != "http://your-server.com") {
97         // Already installed???
98         $burl = URL;
99 } elseif ($burl == "") {
100         // Auto-detect URL
101         $burl = "http://".$SERVER_NAME.$_SERVER['PHP_SELF'];
102         $burl = substr($burl, 0, strpos($burl, "install.php"));
103 }
104
105 // Check if both passwords from SMTP are matching
106 if ((isset($_GET['page']) && ($_GET['page'] == 5))) {
107         // Okay, we have to check it
108         if (!empty($_POST['smtp_user']) && (empty($_POST['smtp_host']))) {
109                 // Hostname not set
110                 OUTPUT_HTML(INSTALL_SMTP_HOSTNAME_EMPTY."<br />");
111                 $_GET['page'] = 3;
112         }
113         if ((empty($_POST['smtp_pass1'])) && (!empty($_POST['smtp_pass2']))) {
114                 // Password is empty
115                 OUTPUT_HTML(INSTALL_SMTP_PASS1_EMPTY."<br />");
116                 $_GET['page'] = 3;
117         }
118         if ((!empty($_POST['smtp_pass1'])) && (empty($_POST['smtp_pass2']))) {
119                 // Password repeat is empty
120                 OUTPUT_HTML(INSTALL_SMTP_PASS2_EMPTY."<br />");
121                 $_GET['page'] = 3;
122         }
123         if ($_POST['smtp_pass1'] != $_POST['smtp_pass1']) {
124                 // Passwords are not matching
125                 OUTPUT_HTML(INSTALL_SMTP_PASS_MISMATCH."<br />");
126                 $_GET['page'] = 3;
127         }
128 }
129
130 // Is MXChange installed or no admin registered so far?
131 if ((!isBooleanConstantAndTrue('mxchange_installed')) || (!isBooleanConstantAndTrue('admin_registered')))
132 {
133         // Set URL for FORM actions
134         define('__BURL_ACTION', $burl);
135
136         // Output page for entered value
137         switch ($_GET['page'])
138         {
139         case "welcome": // Welcome to the installation!
140                 LOAD_TEMPLATE("install_welcome");
141                 break;
142
143         case "1": // Server path, base URL
144                 define('__PATH_LEN'     , strlen(PATH));
145                 define('__BURL_LEN'     , strlen($burl));
146                 define('__TITLE_LEN'    , strlen(MAIN_TITLE));
147                 define('__SLOGAN_LEN'   , strlen(SLOGAN));
148                 define('__WEBMASTER_LEN', (strlen(WEBMASTER) * 3));
149
150                 // Load template
151                 LOAD_TEMPLATE("install_page1");
152                 break;
153
154         case "2": // MySQL data (alone!)
155                 if (empty($mysql['dbase']))  $mysql['dbase']  = "your_database";
156                 if (empty($mysql['login']))  $mysql['login']  = "your_login";
157                 if (empty($mysql['host']))   $mysql['host']   = "localhost";
158                 if (empty($mysql['prefix'])) $mysql['prefix'] = "mxchange_";
159                 if ((sizeof($FATAL) > 0) || (!empty($FATAL[0]))) {
160                         OUTPUT_HTML("<SPAN class=\"install_fatal\">");
161                         foreach ($FATAL as $key=>$err) {
162                                 OUTPUT_HTML("  <STRONG>&middot;</STRONG>&nbsp;".FATAL_NO.($key + 1).":&nbsp;".$err."<br />");
163                         }
164                         OUTPUT_HTML("</SPAN><br />");
165                 }
166                 define('__MYSQL_HOST'  , $mysql['host']);
167                 define('__MYSQL_DBASE' , $mysql['dbase']);
168                 define('__MYSQL_PREFIX', $mysql['prefix']);
169                 define('__MYSQL_LOGIN' , $mysql['login']);
170                 define('__SPATH_VALUE' , $_POST['spath']);
171                 define('__BURL_VALUE'  , $_POST['burl']);
172                 define('__TITLE_VALUE' , $_POST['title']);
173                 define('__SLOGAN_VALUE', $_POST['slogan']);
174                 define('__EMAIL_VALUE' , $_POST['email']);
175
176                 // Load template
177                 LOAD_TEMPLATE("install_page2");
178                 break;
179
180         case "3":
181                 // Set more values
182                 define('__SPATH_VALUE'  , $_POST['spath']);
183                 define('__BURL_VALUE'   , $_POST['burl']);
184                 define('__TITLE_VALUE'  , $_POST['title']);
185                 define('__SLOGAN_VALUE' , $_POST['slogan']);
186                 define('__EMAIL_VALUE'  , $_POST['email']);
187
188                 // Use default SMTP data
189                 $smtpHost  = SMTP_HOSTNAME;
190                 $smtpUser  = SMTP_USER;
191                 $smtpPass1 = SMTP_PASSWORD;
192                 $smtpPass2 = SMTP_PASSWORD;
193
194                 // Overwrite it with the data from sent (failed) form
195                 if (!empty($_POST['smtp_host'])) $smtpHost = $_POST['smtp_host'];
196                 if (!empty($_POST['smtp_user'])) $smtpUser = $_POST['smtp_user'];
197
198                 // MySQL settings
199                 define('__MYSQL_HOST'   , $mysql['host']);
200                 define('__MYSQL_DBASE'  , $mysql['dbase']);
201                 define('__MYSQL_PREFIX' , $mysql['prefix']);
202                 define('__MYSQL_LOGIN'  , $mysql['login']);
203                 define('__MYSQL_PASS1'  , $mysql['pass1']);
204                 define('__MYSQL_PASS2'  , $mysql['pass2']);
205
206                 // Set constants for SMTP data
207                 define('__SMTP_HOST'    , $smtpHost);
208                 define('__SMTP_USER'    , $smtpUser);
209                 define('__SMTP_PASS1'   , $smtpPass1);
210                 define('__SMTP_PASS2'   , $smtpPass2);
211
212                 // Load template
213                 LOAD_TEMPLATE("install_page3");
214                 break;
215
216         case "5": // Misc settings
217                 // General settings
218                 define('__SPATH_VALUE'  , $_POST['spath']);
219                 define('__BURL_VALUE'   , $_POST['burl']);
220                 define('__TITLE_VALUE'  , $_POST['title']);
221                 define('__SLOGAN_VALUE' , $_POST['slogan']);
222                 define('__EMAIL_VALUE'  , $_POST['email']);
223
224                 // MySQL settings
225                 define('__MYSQL_HOST'   , $mysql['host']);
226                 define('__MYSQL_DBASE'  , $mysql['dbase']);
227                 define('__MYSQL_PREFIX' , $mysql['prefix']);
228                 define('__MYSQL_LOGIN'  , $mysql['login']);
229
230                 // SMTP settings
231                 define('__SMTP_HOST'    , $_POST['smtp_host']);
232                 define('__SMTP_USER'    , $_POST['smtp_user']);
233                 define('__SMTP_PASS'    , $_POST['smtp_pass1']);
234                 OUTPUT_HTML("<FORM action=\"".__BURL_ACTION."/install.php?page=finalize\" method=\"POST\" target=\"_self\">
235 <TABLE border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"install_content\">
236 <TR>
237   <TD colspan=\"2\" align=\"center\">
238     <STRONG class=\"install\">".HEADER_TEXT_PAGE5."</STRONG>
239   </TD>
240 </TR>
241 <TR><TD colspan=\"2\" height=\"21\" class=\"seperator\">&nbsp;</TD></TR>
242 <TR>
243   <TD colspan=\"2\"><SPAN class=\"install_intro\">
244     ".TEXT_PAGE_5."
245   </SPAN></TD>
246 </TR>
247 <TR><TD colspan=\"2\" height=\"21\" class=\"seperator\">&nbsp;</TD></TR>
248 <TR>
249   <TD class=\"install\" align=\"right\">".LANG_OUTPUT_MODE.":&nbsp;&nbsp;</TD>
250   <TD>
251     <SELECT name=\"omode\" size=\"1\" class=\"install_select\">
252       <OPTION value=\"render\"");
253                 if (OUTPUT_MODE == "render") OUTPUT_HTML(" selected=\"selected\"");
254                 OUTPUT_HTML(">".MODE_RENDER."</OPTION>
255       <OPTION value=\"direct\"");
256                 if (OUTPUT_MODE == "direct") OUTPUT_HTML(" selected=\"selected\"");
257                 OUTPUT_HTML(">".MODE_DIRECT."</OPTION>
258     </SELECT>
259   </TD>
260 </TR>
261 <TR><TD colspan=\"2\" height=\"10\" class=\"seperator\">&nbsp;</TD></TR>
262 <TR>
263   <TD class=\"install\" align=\"right\">".WARN_NO_PASSWORD.":&nbsp;&nbsp;</TD>
264   <TD>
265     <SELECT name=\"warn_no_pass\" size=\"1\" class=\"install_select\">
266       <OPTION value=\"true\"");
267                 if (warn_no_pass) OUTPUT_HTML(" selected=\"selected\"");
268                 OUTPUT_HTML(">".YES."</OPTION>
269       <OPTION value=\"false\"");
270                 if (!warn_no_pass) OUTPUT_HTML(" selected=\"selected\"");
271                 OUTPUT_HTML(">".NO."</OPTION>
272     </SELECT>
273   </TD>
274 </TR>
275 <TR><TD colspan=\"2\" height=\"10\" class=\"seperator\">&nbsp;</TD></TR>
276 <TR>
277   <TD class=\"install\" align=\"right\">".LANG_WRITE_FOOTER.":&nbsp;&nbsp;</TD>
278   <TD>
279     <SELECT name=\"wfooter\" size=\"1\" class=\"install_select\">
280       <OPTION value=\"true\"");
281                 if (WRITE_FOOTER) OUTPUT_HTML(" selected=\"selected\"");
282                 OUTPUT_HTML(">".YES."</OPTION>
283       <OPTION value=\"false\"");
284                 if (!WRITE_FOOTER) OUTPUT_HTML(" selected=\"selected\"");
285                 OUTPUT_HTML(">".NO."</OPTION>
286     </SELECT>
287   </TD>
288 </TR>
289 <TR><TD colspan=\"2\" height=\"10\" class=\"seperator\">&nbsp;</TD></TR>
290 <TR>
291   <TD class=\"install\" align=\"right\">".INSTALL_ENABLE_BACKLINK.":&nbsp;&nbsp;</TD>
292   <TD>
293     <SELECT name=\"blink\" size=\"1\" class=\"install_select\">
294       <OPTION value=\"true\"");
295                 if (ENABLE_BACKLINK) OUTPUT_HTML(" selected=\"selected\"");
296                 OUTPUT_HTML(">".YES."</OPTION>
297       <OPTION value=\"false\"");
298                 if (!ENABLE_BACKLINK) OUTPUT_HTML(" selected=\"selected\"");
299                 OUTPUT_HTML(">".NO."</OPTION>
300     </SELECT>
301   </TD>
302 </TR>
303 <TR><TD colspan=\"2\" height=\"21\" class=\"seperator\">&nbsp;</TD></TR>
304 <TR>
305   <TD colspan=\"2\" align=\"center\">");
306                 foreach ($mysql as $key=>$value) {
307                         OUTPUT_HTML("    <INPUT type=\"hidden\" name=\"mysql[".$key."]\" value=\"".$value."\">");
308                 }
309                 OUTPUT_HTML("    <INPUT type=\"hidden\" name=\"spath\" value=\"".__SPATH_VALUE."\">
310     <INPUT type=\"hidden\" name=\"burl\" value=\"".__BURL_VALUE."\">
311     <INPUT type=\"hidden\" name=\"title\" value=\"".__TITLE_VALUE."\">
312     <INPUT type=\"hidden\" name=\"slogan\" value=\"".__SLOGAN_VALUE."\">
313     <INPUT type=\"hidden\" name=\"email\" value=\"".__EMAIL_VALUE."\">
314     <INPUT type=\"hidden\" name=\"smtp_host\" value=\"".__SMTP_HOST."\">
315     <INPUT type=\"hidden\" name=\"smtp_user\" value=\"".__SMTP_USER."\">
316     <INPUT type=\"hidden\" name=\"smtp_pass\" value=\"".__SMTP_PASS."\">
317     <INPUT type=\"submit\" class=\"admin_submit submit\" name=\"finalize\" value=\"".NEXT_PAGE."\" class=\"install_submit\">
318   </TD>
319 </TR>
320 <TR><TD colspan=\"2\" height=\"21\" class=\"seperator\">&nbsp;</TD></TR>
321 </TABLE>
322 </FORM>");
323                 break;
324
325         case "finalize": // Write captured data to files
326                 if ((!empty($_POST['finalize'])) && (!isBooleanConstantAndTrue('mxchange_installed'))) {
327                         // You have submitted data then we have to reset the fatal messages
328                         $FATAL = array(); $SQLs = array();
329
330                         // Connect to MySQL server
331                         $link = SQL_CONNECT($mysql['host'], $mysql['login'], $mysql['pass1'], __FILE__, __LINE__);
332                         if ($link) {
333                                 // Seems to work, also right database?
334                                 $db = SQL_SELECT_DB($mysql['dbase'], $link, __FILE__, __LINE__);
335                                 if ($db) {
336                                         // Automatically run install.sql
337                                         if ((file_exists($_POST['spath']."install/tables.sql")) && (file_exists($_POST['spath']."install/menu-".GET_LANGUAGE().".sql"))) {
338                                                 // Both exists so import them
339                                                 foreach (array("tables.sql", "menu-".GET_LANGUAGE().".sql") as $dump) {
340                                                         // Should be save here because file_exists() is there but we check it again. :)
341                                                         $file = secureString($_POST['spath']) . "install/" . $dump;
342                                                         if ((file_exists($file)) && (is_readable($file))) {
343                                                                 // Load the file
344                                                                 $sql = implode("", file($file));
345
346                                                                 // Remove some unwanted chars
347                                                                 $sql = str_replace("\r", "", $sql);
348                                                                 $sql = str_replace("\n\n", "\n", $sql);
349
350                                                                 // And split it up against ;\n ...
351                                                                 $SQLs = array_merge($SQLs, explode(";\n", $sql));
352                                                         }
353                                                 }
354
355                                                 // Are some SQLs found?
356                                                 if (count($SQLs) == 0) {
357                                                         // Abort here
358                                                         ADD_FATAL(INSTALL_SQL_IMPORT_FAILED);
359                                                         return;
360                                                 }
361
362                                                 // Now run all queries through and try to keep out empty or comment queries
363                                                 foreach ($SQLs as $sql) {
364                                                         // Trim spaces away
365                                                         $sql = trim($sql);
366
367                                                         // Is this query not empty and not a comment?
368                                                         if ((!empty($sql)) && (substr($sql, 0, 2) != "--") && (substr($sql, 0, 1) != "#")) {
369                                                                 // Then run it!
370                                                                 SQL_QUERY($sql, __FILE__, __LINE__);
371                                                         }
372                                                 }
373
374                                                 // Ok, all done. So we can write the config data to the php files
375                                                 if ($_POST['spath'] != PATH) install_WriteData($_POST['spath']."inc/config.php", "SERVER-PATH", "define ('PATH', \"", "\");", $_POST['spath'], 0);
376                                                 if ($_POST['burl']  != URL)  install_WriteData($_POST['spath']."inc/config.php", "HOST-URL", "define ('URL', \"", "\");", $_POST['burl'], 0);
377                                                 install_WriteData($_POST['spath']."inc/config.php", "MAIN_TITLE", "define ('MAIN_TITLE', \"", "\");", $_POST['title'], 0);
378                                                 install_WriteData($_POST['spath']."inc/config.php", "SLOGAN", "define ('SLOGAN', \"", "\");", $_POST['slogan'], 0);
379                                                 install_WriteData($_POST['spath']."inc/config.php", "WEBMASTER", "define ('WEBMASTER', \"", "\");", $_POST['email'], 0);
380                                                 install_WriteData($_POST['spath']."inc/config.php", "NULLPASS-WARNING", "define ('warn_no_pass', ", ");", $_POST['warn_no_pass'], 0);
381                                                 install_WriteData($_POST['spath']."inc/config.php", "WRITE-FOOTER", "define ('WRITE_FOOTER', ", ");", $_POST['wfooter'], 0);
382                                                 install_WriteData($_POST['spath']."inc/config.php", "BACKLINK", "define ('ENABLE_BACKLINK', ", ");", $_POST['blink'], 0);
383                                                 // install_WriteData($_POST['spath']."inc/config.php", "OUTPUT-MODE", "define ('OUTPUT_MODE', \"", "\");", $_POST['omode'], 0);
384                                                 install_WriteData($_POST['spath']."inc/config.php", "MYSQL-HOST", "     'host'     => \"", "\",", $mysql['host'], 0);
385                                                 install_WriteData($_POST['spath']."inc/config.php", "MYSQL-DBASE", "    'dbase'    => \"", "\",", $mysql['dbase'], 0);
386                                                 install_WriteData($_POST['spath']."inc/config.php", "MYSQL-LOGIN", "    'login'    => \"", "\",", $mysql['login'], 0);
387                                                 install_WriteData($_POST['spath']."inc/config.php", "MYSQL-PASSWORD", " 'password' => \"", "\",", $mysql['pass1'], 0);
388                                                 install_WriteData($_POST['spath']."inc/config.php", "MYSQL-PREFIX", "define ('_MYSQL_PREFIX', \"", "\");", $mysql['prefix'], 0);
389                                                 install_WriteData($_POST['spath']."inc/config.php", "SMTP-HOSTNAME", "define ('SMTP_HOSTNAME', \"", "\");", $_POST['smtp_host'], 0);
390                                                 install_WriteData($_POST['spath']."inc/config.php", "SMTP-USER", "define ('SMTP_USER', \"", "\");", $_POST['smtp_user'], 0);
391                                                 install_WriteData($_POST['spath']."inc/config.php", "SMTP-PASSWORD", "define ('SMTP_PASSWORD', \"", "\");", $_POST['smtp_pass'], 0);
392                                                 install_WriteData($_POST['spath']."inc/config.php", "INSTALLED", "define ('mxchange_installed', ", ");", "true", 0);
393
394                                                 // Close the link
395                                                 SQL_CLOSE($link, __FILE__, __LINE__);
396                                         }
397                                          else
398                                         {
399                                                 // Installation area not found!
400                                                 ADD_FATAL(INSTALL_MISSING_DUMPS);
401                                         }
402                                 }
403                         }
404                         if ((sizeof($FATAL) > 0) || ($FATAL[0] != ""))
405                         {
406                                 $OUT = "";
407                                 foreach ($FATAL as $value)
408                                 {
409                                         $OUT .= "    <LI>".$value."</LI>\n";
410                                 }
411                                 define('__FATAL_ERROR_LI', $OUT);
412                                 $OUT = "";
413                                 foreach ($mysql as $key=>$value)
414                                 {
415                                         $OUT .= "    <INPUT type=\"hidden\" name=\"mysql[".$key."]\" value=\"".$value."\">\n";
416                                 }
417                                 define('__MYSQL_DATA'   , $OUT);
418                                 define('__SPATH_VALUE'  , $_POST['spath']);
419                                 define('__BURL_VALUE'   , $_POST['burl']);
420                                 define('__TITLE_VALUE'  , $_POST['title']);
421                                 define('__SMTP_HOST'    , $_POST['smtp_host']);
422                                 define('__SMTP_USER'    , $_POST['smtp_user']);
423                                 define('__SMTP_PASS'    , $_POST['smtp_pass']);
424
425                                 OUTPUT_HTML("<FORM action=\"".__BURL_ACTION."/install.php?page=2\" method=\"POST\">
426 <TABLE border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"install_content\">
427 <TR>
428   <TD align=\"center\">
429     <STRONG class=\"install\">".HEADER_MYSQL_ERRORS."</STRONG>
430   </TD>
431 </TR>
432 <TR><TD colspan=\"2\" height=\"21\" class=\"seperator\">&nbsp;</TD></TR>
433 <TR>
434   <TD><SPAN class=\"install_intro\">
435     ".TEXT_MYSQL_ERRORS."
436   </SPAN></TD>
437 </TR>
438 <TR>
439   <TD align=\"center\"><STRONG>
440     <OL>
441 ".__FATAL_ERROR_LI."
442     </OL>
443 ".__MYSQL_DATA."
444     <INPUT type=\"hidden\" name=\"spath\" value=\"".__SPATH_VALUE."\">
445     <INPUT type=\"hidden\" name=\"burl\" value=\"".__BURL_VALUE."\">
446     <INPUT type=\"hidden\" name=\"title\" value=\"".__TITLE_VALUE."\">
447     <INPUT type=\"submit\" class=\"admin_submit\" name=\"ok\" value=\"".RETURN_MYSQL_PAGE."\">
448   </STRONG></TD>
449 </TR>
450 </TABLE>
451 </FORM>");
452                         }
453                          else
454                         {
455                                 // Installation is done!
456                                 $URL = $burl."/install.php?page=finalize";
457                                 LOAD_URL($URL);
458                         }
459                 }
460                  elseif (isBooleanConstantAndTrue('mxchange_installed'))
461                 {
462                         // Redirection after writing data... :-)
463                         LOAD_TEMPLATE("install_finished");
464                 }
465                  else
466                 {
467                         // Something goes wrong during installation! :-(
468                         ADD_FATAL(INSTALL_FINALIZER_FAILED);
469                         include ("inc/fatal_errors.php");
470                 }
471                 break;
472
473         default:
474                 OUTPUT_HTML("    <STRONG class=\"install_error\">".WRONG_PAGE."</STRONG>");
475                 break;
476         }
477 }
478  else
479 {
480         ADD_FATAL(ALREADY_INSTALLED);
481 }
482 //
483 ?>