thomascube
2011-09-22 ef4998c11084b2c99f8af9976f9860d5f7709a0f
commit | author | age
8b8bcc 1 <?php
fee8c6 2
434869 3 /*
T 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
8b8bcc 31 ini_set('error_reporting', E_ALL&~E_NOTICE);
T 32 ini_set('display_errors', 1);
33
47124c 34 define('INSTALL_PATH', realpath(dirname(__FILE__) . '/../').'/');
bba657 35 define('RCMAIL_CONFIG_DIR', INSTALL_PATH . 'config');
T 36
afe50a 37 $include_path  = INSTALL_PATH . 'program/lib' . PATH_SEPARATOR;
T 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
47124c 42 set_include_path($include_path);
T 43
fee8c6 44 require_once 'utils.php';
2c3d81 45 require_once 'main.inc';
47124c 46
fee8c6 47 session_start();
c06067 48
S 49 $RCI = rcube_install::get_instance();
50 $RCI->load_config();
51
7d7f67 52 if (isset($_GET['_getfile']) && in_array($_GET['_getfile'], array('main', 'db'))) {
T 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   }
c06067 64 }
S 65
32eb29 66 if ($RCI->configured && ($RCI->getprop('enable_installer') || $_SESSION['allowinstaller']) &&
T 67     isset($_GET['_mergeconfig']) && in_array($_GET['_mergeconfig'], array('main', 'db'))) {
e10712 68   $filename = $_GET['_mergeconfig'] . '.inc.php';
T 69
70   header('Content-type: text/plain');
71   header('Content-Disposition: attachment; filename="'.$filename.'"');
403f0b 72
e10712 73   $RCI->merge_config();
T 74   echo $RCI->create_config($_GET['_mergeconfig'], true);
75   exit;
76 }
77
b45aed 78 // go to 'check env' step if we have a local configuration
e10712 79 if ($RCI->configured && empty($_REQUEST['_step'])) {
b45aed 80   header("Location: ./?_step=1");
e10712 81   exit;
T 82 }
83
8b8bcc 84 ?>
354978 85 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
T 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>
e019f2 89 <title>Roundcube Webmail Installer</title>
b1c154 90 <meta name="Robots" content="noindex,nofollow" />
A 91 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
354978 92 <link rel="stylesheet" type="text/css" href="styles.css" />
c5042d 93 <script type="text/javascript" src="client.js"></script>
354978 94 </head>
T 95
96 <body>
97
98 <div id="banner">
e6bb83 99   <div class="banner-bg"></div>
T 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>
354978 106
T 107 <div id="content">
108
109 <?php
967b34 110
T 111   // exit if installation is complete
112   if ($RCI->configured && !$RCI->getprop('enable_installer') && !$_SESSION['allowinstaller']) {
e01084 113     // header("HTTP/1.0 404 Not Found");
967b34 114     echo '<h2 class="error">The installer is disabled!</h2>';
32eb29 115     echo '<p>To enable it again, set <tt>$rcmail_config[\'enable_installer\'] = true;</tt> in RCMAIL_CONFIG_DIR/main.inc.php</p>';
967b34 116     echo '</div></body></html>';
T 117     exit;
118   }
b3f9df 119   
354978 120 ?>
T 121
e019f2 122 <h1>Roundcube Webmail Installer</h1>
967b34 123
354978 124 <ol id="progress">
T 125 <?php
126   
127   foreach (array('Check environment', 'Create config', 'Test config') as $i => $item) {
128     $j = $i + 1;
b3f9df 129     $link = ($RCI->step >= $j || $RCI->configured) ? '<a href="./index.php?_step='.$j.'">' . Q($item) . '</a>' : Q($item);
354978 130     printf('<li class="step%d%s">%s</li>', $j+1, $RCI->step > $j ? ' passed' : ($RCI->step == $j ? ' current' : ''), $link);
T 131   }
132 ?>
133 </ol>
134
135 <?php
0ff635 136 $include_steps = array('./welcome.html', './check.php', './config.php', './test.php');
354978 137
T 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">
e6bb83 150   Installer by the Roundcube Dev Team. Copyright &copy; 2008-2011 - Published under the GNU Public License;&nbsp;
ad43e6 151   Icons by <a href="http://famfamfam.com">famfamfam</a>
354978 152 </div>
T 153 </body>
154 </html>