index.php 7.0 KB

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