]> git.donarmstrong.com Git - roundcube.git/blob - installer/index.php
Merge commit 'upstream/0.7'
[roundcube.git] / installer / index.php
1 <?php
2
3 /*
4  +-------------------------------------------------------------------------+
5  | Roundcube Webmail setup tool                                            |
6  | Version 0.6                                                             |
7  |                                                                         |
8  | Copyright (C) 2009-2011, 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 version 2          |
12  | as published by the Free Software Foundation.                           |
13  |                                                                         |
14  | This program is distributed in the hope that it will be useful,         |
15  | but WITHOUT ANY WARRANTY; without even the implied warranty of          |
16  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           |
17  | GNU General Public License for more details.                            |
18  |                                                                         |
19  | You should have received a copy of the GNU General Public License along |
20  | with this program; if not, write to the Free Software Foundation, Inc., |
21  | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.             |
22  |                                                                         |
23  +-------------------------------------------------------------------------+
24  | Author: Thomas Bruederli <roundcube@gmail.com>                          |
25  +-------------------------------------------------------------------------+
26
27  $Id$
28
29 */
30
31 ini_set('error_reporting', E_ALL&~E_NOTICE);
32 ini_set('display_errors', 1);
33
34 define('INSTALL_PATH', realpath(dirname(__FILE__) . '/../').'/');
35 define('RCMAIL_CONFIG_DIR', INSTALL_PATH . 'config');
36
37 $include_path  = INSTALL_PATH . 'program/lib' . PATH_SEPARATOR;
38 $include_path .= INSTALL_PATH . 'program' . PATH_SEPARATOR;
39 $include_path .= INSTALL_PATH . 'program/include' . PATH_SEPARATOR;
40 $include_path .= ini_get('include_path');
41
42 set_include_path($include_path);
43
44 require_once 'utils.php';
45 require_once 'main.inc';
46
47 session_start();
48
49 $RCI = rcube_install::get_instance();
50 $RCI->load_config();
51
52 if (isset($_GET['_getfile']) && in_array($_GET['_getfile'], array('main', 'db'))) {
53   $filename = $_GET['_getfile'] . '.inc.php';
54   if (!empty($_SESSION[$filename])) {
55     header('Content-type: text/plain');
56     header('Content-Disposition: attachment; filename="'.$filename.'"');
57     echo $_SESSION[$filename];
58     exit;
59   }
60   else {
61     header('HTTP/1.0 404 Not found');
62     die("The requested configuration was not found. Please run the installer from the beginning.");
63   }
64 }
65
66 if ($RCI->configured && ($RCI->getprop('enable_installer') || $_SESSION['allowinstaller']) &&
67     isset($_GET['_mergeconfig']) && in_array($_GET['_mergeconfig'], array('main', 'db'))) {
68   $filename = $_GET['_mergeconfig'] . '.inc.php';
69
70   header('Content-type: text/plain');
71   header('Content-Disposition: attachment; filename="'.$filename.'"');
72
73   $RCI->merge_config();
74   echo $RCI->create_config($_GET['_mergeconfig'], true);
75   exit;
76 }
77
78 // go to 'check env' step if we have a local configuration
79 if ($RCI->configured && empty($_REQUEST['_step'])) {
80   header("Location: ./?_step=1");
81   exit;
82 }
83
84 ?>
85 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
86         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
87 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
88 <head>
89 <title>Roundcube Webmail Installer</title>
90 <meta name="Robots" content="noindex,nofollow" />
91 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
92 <link rel="stylesheet" type="text/css" href="styles.css" />
93 <script type="text/javascript" src="client.js"></script>
94 </head>
95
96 <body>
97
98 <div id="banner">
99   <div class="banner-bg"></div>
100   <div class="banner-logo"><a href="http://roundcube.net"><img src="images/rcube_logo.gif" width="210" height="55" border="0" alt="Roundcube - Open source webmail project" /></a></div>
101 </div>
102
103 <div id="topnav">
104   <a href="http://trac.roundcube.net/wiki/Howto_Install">How-to Wiki</a>
105 </div>
106
107 <div id="content">
108
109 <?php
110
111   // exit if installation is complete
112   if ($RCI->configured && !$RCI->getprop('enable_installer') && !$_SESSION['allowinstaller']) {
113     // header("HTTP/1.0 404 Not Found");
114     echo '<h2 class="error">The installer is disabled!</h2>';
115     echo '<p>To enable it again, set <tt>$rcmail_config[\'enable_installer\'] = true;</tt> in RCMAIL_CONFIG_DIR/main.inc.php</p>';
116     echo '</div></body></html>';
117     exit;
118   }
119   
120 ?>
121
122 <h1>Roundcube Webmail Installer</h1>
123
124 <ol id="progress">
125 <?php
126   
127   foreach (array('Check environment', 'Create config', 'Test config') as $i => $item) {
128     $j = $i + 1;
129     $link = ($RCI->step >= $j || $RCI->configured) ? '<a href="./index.php?_step='.$j.'">' . Q($item) . '</a>' : Q($item);
130     printf('<li class="step%d%s">%s</li>', $j+1, $RCI->step > $j ? ' passed' : ($RCI->step == $j ? ' current' : ''), $link);
131   }
132 ?>
133 </ol>
134
135 <?php
136 $include_steps = array('./welcome.html', './check.php', './config.php', './test.php');
137
138 if ($include_steps[$RCI->step]) {
139   include $include_steps[$RCI->step];
140 }
141 else {
142   header("HTTP/1.0 404 Not Found");
143   echo '<h2 class="error">Invalid step</h2>';
144 }
145
146 ?>
147 </div>
148
149 <div id="footer">
150   Installer by the Roundcube Dev Team. Copyright &copy; 2008-2011 - Published under the GNU Public License;&nbsp;
151   Icons by <a href="http://famfamfam.com">famfamfam</a>
152 </div>
153 </body>
154 </html>