Updated copyright notice as there are changes in this year
[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 - 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')) || (!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 // Init some things
50 FILTER_INIT_TIMEZONE(array());
51 FILTER_INIT_RANDOMIZER();
52 FILTER_INIT_RANDOM_NUMBER();
53
54 // Init variables
55 $GLOBALS['install_mysql'] = array();
56 if ((isPostRequestElementSet('mysql')) && (ifPostContainsSelections('mysql'))) {
57         // Transfer 'mysql' array
58         $GLOBALS['install_mysql'] = postRequestElement('mysql');
59 } // END - if
60
61 // Check if both passwords from SMTP are matching
62 if ((isGetRequestElementSet('install_page') && (getRequestElement('install_page') == 5))) {
63         // Okay, we have to check it
64         if (isPostRequestElementSet('smtp_user') && (!isPostRequestElementSet('smtp_host'))) {
65                 // Hostname not set
66                 addToInstallContent('<div class="para">{--INSTALLER_SMTP_HOSTNAME_EMPTY--}</div>');
67                 setGetRequestElement('install_page', 3);
68         } // END - if
69
70         if ((!isPostRequestElementSet('smtp_password1')) && (isPostRequestElementSet('smtp_password2'))) {
71                 // Password is empty
72                 addToInstallContent('<div class="para">{--INSTALLER_SMTP_PASSWORD1_EMPTY--}</div>');
73                 setGetRequestElement('install_page', 3);
74         } // END - if
75
76         if ((isPostRequestElementSet('smtp_password1')) && (!isPostRequestElementSet('smtp_password2'))) {
77                 // Password repeat is empty
78                 addToInstallContent('<div class="para">{--INSTALLER_SMTP_PASSWORD2_EMPTY--}</div>');
79                 setGetRequestElement('install_page', 3);
80         } // END - if
81
82         if (postRequestElement('smtp_password1') != postRequestElement('smtp_password1')) {
83                 // Passwords are not matching
84                 addToInstallContent('<div class="para">{--INSTALLER_SMTP_PASS_MISMATCH--}</div>');
85                 setGetRequestElement('install_page', 3);
86         } // END - if
87 } // END - if
88
89 // Is the mailer installed or no admin registered so far?
90 if ((!isInstalled()) || (!isAdminRegistered())) {
91         // Construct include file name
92         $inc = 'inc/install/install_page_' . getRequestElement('install_page') . '.php';
93
94         // Is the include file there?
95         if (isIncludeReadable($inc)) {
96                 // Then load it
97                 loadIncludeOnce($inc);
98         } else {
99                 // Not found, may be invalid page
100                 logDebugMessage(__FILE__, __LINE__, sprintf("Wrong install_page=%s detected", getRequestElement('install_page')));
101                 addTemplateToInstallContent('admin_settings_unsaved', '{%message,INSTALLER_WRONG_PAGE=' . getRequestElement('install_page') . '%}');
102         }
103 } else {
104         // Already installed!
105         addFatalMessage(__FILE__, __LINE__, '{--MAILER_ALREADY_INSTALLED--}');
106 }
107
108 // [EOF]
109 ?>