Renamed language id, commented out a little noisy debug line :)
[mailer.git] / inc / install-inc.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                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  * $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 // Load extension timezone
44 loadExtension('timezone', 'test');
45
46 // Set config entry
47 setConfigEntry('timezone', 'Europe/Berlin');
48
49 // And init timezone
50 FILTER_INIT_TIMEZONE(array());
51
52 // Init variables
53 $GLOBALS['install_mysql'] = array();
54 if ((isPostRequestElementSet('mysql')) && (ifPostContainsSelections('mysql'))) {
55         // Transfer 'mysql' array
56         $GLOBALS['install_mysql'] = postRequestElement('mysql');
57 } // END - if
58
59 // Check if both passwords from SMTP are matching
60 if ((isGetRequestElementSet('install_page') && (getRequestElement('install_page') == 5))) {
61         // Okay, we have to check it
62         if (isPostRequestElementSet('smtp_user') && (!isPostRequestElementSet('smtp_host'))) {
63                 // Hostname not set
64                 addToInstallContent('<div class="para">{--INSTALLER_SMTP_HOSTNAME_EMPTY--}</div>');
65                 setGetRequestElement('install_page', 3);
66         } // END - if
67
68         if ((!isPostRequestElementSet('smtp_pass1')) && (isPostRequestElementSet('smtp_pass2'))) {
69                 // Password is empty
70                 addToInstallContent('<div class="para">{--INSTALLER_SMTP_PASSWORD1_EMPTY--}</div>');
71                 setGetRequestElement('install_page', 3);
72         } // END - if
73
74         if ((isPostRequestElementSet('smtp_pass1')) && (!isPostRequestElementSet('smtp_pass2'))) {
75                 // Password repeat is empty
76                 addToInstallContent('<div class="para">{--INSTALLER_SMTP_PASSWORD2_EMPTY--}</div>');
77                 setGetRequestElement('install_page', 3);
78         } // END - if
79
80         if (postRequestElement('smtp_pass1') != postRequestElement('smtp_pass1')) {
81                 // Passwords are not matching
82                 addToInstallContent('<div class="para">{--INSTALLER_SMTP_PASS_MISMATCH--}</div>');
83                 setGetRequestElement('install_page', 3);
84         } // END - if
85 } // END - if
86
87 // Is the mailer installed or no admin registered so far?
88 if ((!isInstalled()) || (!isAdminRegistered())) {
89         // Construct include file name
90         $inc = 'inc/install/install_page_' . getRequestElement('install_page');
91
92         // Is the include file there?
93         if (isIncludeReadable($inc)) {
94                 // Then load it
95                 loadIncludeOnce($inc);
96         } else {
97                 // Not found, may be invalid page
98                 logDebugMessage(__FILE__, __LINE__, sprintf("Wrong install_page=%s detected", getRequestElement('install_page')));
99                 addTemplateToInstallContent('admin_settings_unsaved', '{--WRONG_PAGE--}');
100         }
101 } else {
102         // Already installed!
103         addFatalMessage(__FILE__, __LINE__, '{--MAILER_ALREADY_INSTALLED--}');
104 }
105
106 // [EOF]
107 ?>