install.php 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. if (!isset($_SERVER['HTTP_HOST'])) {
  4. exit('This script cannot be run from the CLI. Run it from a browser.');
  5. }
  6. use Symfony\Component\Translation\Translator;
  7. use Symfony\Component\Translation\Loader\YamlFileLoader;
  8. use Symfony\Component\Yaml\Yaml;
  9. use Symfony\Component\Dotenv\Dotenv;
  10. require_once __DIR__.'/../app/ChamiloRequirements.php';
  11. require_once __DIR__.'/../vendor/autoload.php';
  12. // check for installed system
  13. $paramFile = __DIR__.'/../.env';
  14. $paramFileDist = __DIR__.'/../.env.dist';
  15. $configFile = __DIR__.'/../app/config/configuration.php';
  16. $upgrade = false;
  17. if (file_exists($paramFile)) {
  18. $dotEnv = new Dotenv();
  19. $dotEnv->load($paramFile);
  20. $installed = getenv('APP_INSTALLED');
  21. $data = Yaml::parse($paramFile);
  22. if (!empty($installed)) {
  23. // Redirect to upgrade process
  24. header('Location: /install/flow/chamilo_install/welcome');
  25. exit;
  26. }
  27. } else {
  28. copy($paramFileDist, $paramFile);
  29. }
  30. if (file_exists($paramFile) && file_exists($configFile)) {
  31. $upgrade = true;
  32. }
  33. $url = 'index.php/install/flow/chamilo_install/welcome';
  34. if ($upgrade) {
  35. $url = 'index.php/install/flow/chamilo_upgrade/welcome';
  36. }
  37. /**
  38. * @todo Identify correct locale (headers?)
  39. */
  40. $locale = 'en';
  41. $collection = new ChamiloRequirements();
  42. $translator = new Translator($locale);
  43. $majorProblems = $collection->getFailedRequirements();
  44. $minorProblems = $collection->getFailedRecommendations();
  45. $translator->addLoader('yml', new YamlFileLoader());
  46. $translator->addResource(
  47. 'yml',
  48. __DIR__.'/../src/InstallerBundle/Resources/translations/messages.'.$locale.'.yml',
  49. $locale
  50. );
  51. function iterateRequirements(array $collection, $translator)
  52. {
  53. foreach ($collection as $requirement) :
  54. ?>
  55. <tr>
  56. <td class="dark">
  57. <?php if ($requirement->isFulfilled()) : ?>
  58. <span class="icon-yes">
  59. <?php elseif (!$requirement->isOptional()) : ?>
  60. <span class="icon-no">
  61. <?php else : ?>
  62. <span class="icon-warning">
  63. <?php endif; ?>
  64. <?php echo $requirement->getTestMessage(); ?>
  65. </span>
  66. <?php if ($requirement instanceof CliRequirement && !$requirement->isFulfilled()) : ?>
  67. <pre class="output"><?php echo $requirement->getOutput(); ?></pre>
  68. <?php endif; ?>
  69. </td>
  70. <td>
  71. <?php
  72. if ($requirement->isFulfilled()) {
  73. echo '<h4><span class="label label-success"><i class="fa fa-check-circle"></i> '.$translator->trans(
  74. 'process.step.check.requirement_status.ok'
  75. ).'</span></h4>';
  76. } else {
  77. if (!$requirement->isOptional()) {
  78. echo '<h4><span class="label label-danger"><i class="fa fa-exclamation-triangle"> </i> '.$translator->trans(
  79. 'process.step.check.requirement_status.danger'
  80. ).'</span></h4>';
  81. } else {
  82. echo '<h4><span class="label label-warning"><i class="fa fa-exclamation-triangle"></i> '.$translator->trans(
  83. 'process.step.check.requirement_status.warning'
  84. ).'</span></h4>';
  85. }
  86. $requirement->getHelpHtml();
  87. echo '</span>';
  88. }
  89. ?>
  90. </td>
  91. </tr>
  92. <?php
  93. endforeach;
  94. }
  95. ?>
  96. <!doctype html>
  97. <!--[if IE 7 ]>
  98. <html class="no-js ie ie7" lang="en"> <![endif]-->
  99. <!--[if IE 8 ]>
  100. <html class="no-js ie ie8" lang="en"> <![endif]-->
  101. <!--[if IE 9 ]>
  102. <html class="no-js ie ie9" lang="en"> <![endif]-->
  103. <!--[if (gte IE 10)|!(IE)]><!-->
  104. <html class="no-js" lang="en"> <!--<![endif]-->
  105. <head>
  106. <meta charset="utf-8">
  107. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  108. <title><?php echo $translator->trans('title'); ?></title>
  109. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  110. <link rel="stylesheet" type="text/css" href="build/chamilo_style.css"/>
  111. <link rel="stylesheet" type="text/css" href="css/install.css"/>
  112. <script type="text/javascript" src="build/chamilo.js"></script>
  113. <script type="text/javascript">
  114. $(function () {
  115. $('.progress-bar li:last-child em.fix-bg').width($('.progress-bar li:last-child').width() / 2);
  116. $('.progress-bar li:first-child em.fix-bg').width($('.progress-bar li:first-child').width() / 2);
  117. var splash = $('div.start-box'),
  118. body = $('body'),
  119. winHeight = $(window).height();
  120. $('#begin-install').click(function () {
  121. splash.hide();
  122. body.css({'overflow': 'visible', 'height': 'auto'});
  123. });
  124. if ('localStorage' in window && window['localStorage'] !== null) {
  125. if (!localStorage.getItem('oroInstallSplash')) {
  126. splash.show().height(winHeight);
  127. body.css({'overflow': 'hidden', 'height': winHeight});
  128. localStorage.setItem('oroInstallSplash', true);
  129. }
  130. }
  131. <?php if (!count($majorProblems)) : ?>
  132. // initiate application in background
  133. // $.get('app_dev.php/installer/flow/chamilo_installer/configure');
  134. <?php endif; ?>
  135. });
  136. </script>
  137. </head>
  138. <body>
  139. <div class="container">
  140. <div class="page-header">
  141. <h1 class="logo"><?php echo $translator->trans('title'); ?></h1>
  142. </div>
  143. <div class="content">
  144. <div class="page-title">
  145. <h2><?php echo $translator->trans('process.step.check.header'); ?></h2>
  146. </div>
  147. <?php if (count($majorProblems)) : ?>
  148. <div class="alert alert-warning" role="alert">
  149. <ul>
  150. <li><?php echo $translator->trans('process.step.check.invalid'); ?></li>
  151. <?php if ($collection->hasPhpIniConfigIssue()): ?>
  152. <li id="phpini">*
  153. <?php
  154. if ($collection->getPhpIniConfigPath()) :
  155. echo $translator->trans(
  156. 'process.step.check.phpchanges',
  157. array(
  158. '%path%' => $collection->getPhpIniConfigPath(
  159. ),
  160. )
  161. );
  162. else :
  163. echo $translator->trans(
  164. 'process.step.check.phpchanges'
  165. );
  166. endif;
  167. ?>
  168. </li>
  169. <?php endif; ?>
  170. </ul>
  171. </div>
  172. <?php endif; ?>
  173. <?php
  174. $requirements = array(
  175. 'mandatory' => $collection->getMandatoryRequirements(),
  176. 'php' => $collection->getPhpIniRequirements(),
  177. 'chamilo' => $collection->getChamiloRequirements(),
  178. 'cli' => $collection->getCliRequirements(),
  179. 'optional' => $collection->getRecommendations(),
  180. );
  181. foreach ($requirements as $type => $requirement) : ?>
  182. <table class="table table-striped">
  183. <col width="75%" valign="top">
  184. <col width="25%" valign="top">
  185. <thead>
  186. <tr>
  187. <th><?php echo $translator->trans('process.step.check.table.'.$type); ?></th>
  188. <th><?php echo $translator->trans('process.step.check.table.status'); ?></th>
  189. </tr>
  190. </thead>
  191. <tbody>
  192. <?php iterateRequirements($requirement, $translator); ?>
  193. </tbody>
  194. </table>
  195. <?php endforeach; ?>
  196. </div>
  197. <hr/>
  198. <br/>
  199. <div class="install-form-actions">
  200. <?php if (count($majorProblems) || count($minorProblems)): ?>
  201. <a href="install.php" class="btn btn-default btn-lg">
  202. <i class="fa fa-refresh"></i>
  203. <?php echo $translator->trans('process.button.refresh'); ?>
  204. </a>
  205. <?php endif; ?>
  206. <a href="<?php echo count($majorProblems) ? 'javascript: void(0);' : $url; ?>"
  207. class="btn btn-lg btn-primary <?php echo count($majorProblems) ? 'disabled' : 'primary'; ?>">
  208. <i class="fa fa-chevron-right"></i> <?php echo $translator->trans('process.button.continue'); ?>
  209. </a>
  210. </div>
  211. </div>
  212. <hr/>
  213. <br/>
  214. <footer class="footer">
  215. <div class="container">
  216. <p class="text-muted">
  217. Chamilo
  218. </p>
  219. </div>
  220. </footer>
  221. </body>
  222. </html>