1<?php
2
3/**
4 +-------------------------------------------------------------------------+
5 | Roundcube Webmail setup tool                                            |
6 | Version 1.5.1                                                           |
7 |                                                                         |
8 | Copyright (C) The Roundcube Dev Team                                    |
9 |                                                                         |
10 | This program is free software: you can redistribute it and/or modify    |
11 | it under the terms of the GNU General Public License (with exceptions   |
12 | for skins & plugins) as published by the Free Software Foundation,      |
13 | either version 3 of the License, or (at your option) any later version. |
14 |                                                                         |
15 | This file forms part of the Roundcube Webmail Software for which the    |
16 | following exception is added: Plugins and Skins which merely make       |
17 | function calls to the Roundcube Webmail Software, and for that purpose  |
18 | include it by reference shall not be considered modifications of        |
19 | the software.                                                           |
20 |                                                                         |
21 | If you wish to use this file in another project or create a modified    |
22 | version that will not be part of the Roundcube Webmail Software, you    |
23 | may remove the exception above and use this source code under the       |
24 | original version of the license.                                        |
25 |                                                                         |
26 | This program is distributed in the hope that it will be useful,         |
27 | but WITHOUT ANY WARRANTY; without even the implied warranty of          |
28 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the            |
29 | GNU General Public License for more details.                            |
30 |                                                                         |
31 | You should have received a copy of the GNU General Public License       |
32 | along with this program.  If not, see http://www.gnu.org/licenses/.     |
33 |                                                                         |
34 +-------------------------------------------------------------------------+
35 | Author: Thomas Bruederli <roundcube@gmail.com>                          |
36 +-------------------------------------------------------------------------+
37*/
38
39ini_set('display_errors', 1);
40
41define('INSTALL_PATH', realpath(__DIR__ . '/../').'/');
42
43require INSTALL_PATH . 'program/include/iniset.php';
44
45if (function_exists('session_start')) {
46    session_start();
47}
48
49$RCI = rcmail_install::get_instance();
50$RCI->load_config();
51
52if (isset($_GET['_getconfig'])) {
53    $filename = 'config.inc.php';
54    if (!empty($_SESSION['config']) && $_GET['_getconfig'] == 2) {
55        $path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $filename;
56        @unlink($path);
57        file_put_contents($path, $_SESSION['config']);
58        exit;
59    }
60
61    if (!empty($_SESSION['config'])) {
62        header('Content-type: text/plain');
63        header('Content-Disposition: attachment; filename="'.$filename.'"');
64        echo $_SESSION['config'];
65        exit;
66    }
67
68    header('HTTP/1.0 404 Not found');
69    die("The requested configuration was not found. Please run the installer from the beginning.");
70}
71
72if (
73    $RCI->configured
74    && ($RCI->getprop('enable_installer') || $_SESSION['allowinstaller']) &&
75    !empty($_GET['_mergeconfig'])
76) {
77    $filename = 'config.inc.php';
78
79    header('Content-type: text/plain');
80    header('Content-Disposition: attachment; filename="'.$filename.'"');
81
82    $RCI->merge_config();
83    echo $RCI->create_config();
84    exit;
85}
86
87// go to 'check env' step if we have a local configuration
88if ($RCI->configured && empty($_REQUEST['_step'])) {
89    header("Location: ./?_step=1");
90    exit;
91}
92
93?>
94<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
95<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
96<head>
97<title>Roundcube Webmail Installer</title>
98<meta name="Robots" content="noindex,nofollow" />
99<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
100<link rel="stylesheet" type="text/css" href="styles.css" />
101<script type="text/javascript" src="client.js"></script>
102</head>
103
104<body>
105
106<div id="banner">
107  <div class="banner-bg"></div>
108  <div class="banner-logo"><a href="http://roundcube.net"><img src="images/roundcube_logo.png" width="210" height="55" border="0" alt="Roundcube - open source webmail software" /></a></div>
109</div>
110
111<div id="topnav">
112  <a href="https://github.com/roundcube/roundcubemail/wiki/Installation">How-to Wiki</a>
113</div>
114
115<div id="content">
116
117<?php
118
119// exit if installation is complete
120if ($RCI->configured && !$RCI->getprop('enable_installer') && empty($_SESSION['allowinstaller'])) {
121    // header("HTTP/1.0 404 Not Found");
122    if ($RCI->configured && $RCI->legacy_config) {
123        echo '<h2 class="error">Your configuration needs to be migrated!</h2>';
124        echo '<p>We changed the configuration files structure and your installation needs to be updated accordingly.</p>';
125        echo '<p>Please run the <tt>bin/update.sh</tt> script from the command line or set <p>&nbsp; <tt>$rcube_config[\'enable_installer\'] = true;</tt></p>';
126        echo ' in your RCUBE_CONFIG_DIR/main.inc.php to let the installer help you migrating it.</p>';
127    }
128    else {
129        echo '<h2 class="error">The installer is disabled!</h2>';
130        echo '<p>To enable it again, set <tt>$config[\'enable_installer\'] = true;</tt> in RCUBE_CONFIG_DIR/config.inc.php</p>';
131    }
132
133    echo '</div></body></html>';
134    exit;
135}
136
137?>
138
139<h1>Roundcube Webmail Installer</h1>
140
141<ol id="progress">
142<?php
143$include_steps = [
144    1 => './check.php',
145    2 => './config.php',
146    3 => './test.php',
147];
148
149if (!in_array($RCI->step, array_keys($include_steps))) {
150    $RCI->step = 1;
151}
152
153foreach (['Check environment', 'Create config', 'Test config'] as $i => $item) {
154    $j = $i + 1;
155    $link = ($RCI->step >= $j || $RCI->configured) ? '<a href="./index.php?_step='.$j.'">' . rcube::Q($item) . '</a>' : rcube::Q($item);
156    printf('<li class="step%d%s">%s</li>', $j+1, $RCI->step > $j ? ' passed' : ($RCI->step == $j ? ' current' : ''), $link);
157}
158?>
159</ol>
160
161<?php
162
163include $include_steps[$RCI->step];
164
165?>
166</div>
167
168<div id="footer">
169  Installer by the Roundcube Dev Team. Copyright &copy; 2008-2021 – Published under the GNU Public License;&nbsp;
170  Icons by <a href="http://famfamfam.com">famfamfam</a>
171</div>
172</body>
173</html>
174