PageRenderTime 650ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/web/config.php

https://github.com/pirrat/Consilio
PHP | 195 lines | 160 code | 32 blank | 3 comment | 37 complexity | 37d97dad61e58865a4174202ee3b0ad3 MD5 | raw file
  1. <?php
  2. if (!isset($_SERVER['HTTP_HOST'])) {
  3. die('This script cannot be run from the CLI. Run it from a browser.');
  4. }
  5. $majorProblems = array();
  6. $minorProblems = array();
  7. $phpini = false;
  8. // minimum
  9. if (!version_compare(phpversion(), '5.3.2', '>=')) {
  10. $version = phpversion();
  11. $majorProblems[] = <<<EOF
  12. You are running PHP version "<strong>$version</strong>", but Symfony
  13. needs at least PHP "<strong>5.3.2</strong>" to run. Before using Symfony, install
  14. PHP "<strong>5.3.2</strong>" or newer.
  15. EOF;
  16. }
  17. if (!is_writable(__DIR__ . '/../app/cache')) {
  18. $majorProblems[] = 'Change the permissions of the "<strong>app/cache/</strong>"
  19. directory so that the web server can write into it.';
  20. }
  21. if (!is_writable(__DIR__ . '/../app/logs')) {
  22. $majorProblems[] = 'Change the permissions of the "<strong>app/logs/</strong>"
  23. directory so that the web server can write into it.';
  24. }
  25. // extensions
  26. if (!class_exists('DomDocument')) {
  27. $minorProblems[] = 'Install and enable the <strong>php-xml</strong> module.';
  28. }
  29. if (!defined('LIBXML_COMPACT')) {
  30. $minorProblems[] = 'Upgrade your <strong>php-xml</strong> extension with a newer libxml.';
  31. }
  32. if (!((function_exists('apc_store') && ini_get('apc.enabled')) || function_exists('eaccelerator_put') && ini_get('eaccelerator.enable') || function_exists('xcache_set'))) {
  33. $minorProblems[] = 'Install and enable a <strong>PHP accelerator</strong> like APC (highly recommended).';
  34. }
  35. if (!function_exists('token_get_all')) {
  36. $minorProblems[] = 'Install and enable the <strong>Tokenizer</strong> extension.';
  37. }
  38. if (!function_exists('mb_strlen')) {
  39. $minorProblems[] = 'Install and enable the <strong>mbstring</strong> extension.';
  40. }
  41. if (!function_exists('iconv')) {
  42. $minorProblems[] = 'Install and enable the <strong>iconv</strong> extension.';
  43. }
  44. if (!function_exists('utf8_decode')) {
  45. $minorProblems[] = 'Install and enable the <strong>XML</strong> extension.';
  46. }
  47. if (PHP_OS != 'WINNT' && !function_exists('posix_isatty')) {
  48. $minorProblems[] = 'Install and enable the <strong>php_posix</strong> extension (used to colorize the CLI output).';
  49. }
  50. if (!class_exists('Locale')) {
  51. $minorProblems[] = 'Install and enable the <strong>intl</strong> extension.';
  52. } else {
  53. $version = '';
  54. if (defined('INTL_ICU_VERSION')) {
  55. $version = INTL_ICU_VERSION;
  56. } else {
  57. $reflector = new \ReflectionExtension('intl');
  58. ob_start();
  59. $reflector->info();
  60. $output = strip_tags(ob_get_clean());
  61. preg_match('/^ICU version (.*)$/m', $output, $matches);
  62. $version = $matches[1];
  63. }
  64. if (!version_compare($matches[1], '4.0', '>=')) {
  65. $minorProblems[] = 'Upgrade your <strong>intl</strong> extension with a newer ICU version (4+).';
  66. }
  67. }
  68. if (!class_exists('SQLite3') && !in_array('sqlite', PDO::getAvailableDrivers())) {
  69. $majorProblems[] = 'Install and enable the <strong>SQLite3</strong> or <strong>PDO_SQLite</strong> extension.';
  70. }
  71. if (!function_exists('json_encode')) {
  72. $majorProblems[] = 'Install and enable the <strong>json</strong> extension.';
  73. }
  74. // php.ini
  75. if (!ini_get('date.timezone')) {
  76. $phpini = true;
  77. $majorProblems[] = 'Set the "<strong>date.timezone</strong>" setting in php.ini<a href="#phpini">*</a> (like Europe/Paris).';
  78. }
  79. if (ini_get('short_open_tag')) {
  80. $phpini = true;
  81. $minorProblems[] = 'Set <strong>short_open_tag</strong> to <strong>off</strong> in php.ini<a href="#phpini">*</a>.';
  82. }
  83. if (ini_get('magic_quotes_gpc')) {
  84. $phpini = true;
  85. $minorProblems[] = 'Set <strong>magic_quotes_gpc</strong> to <strong>off</strong> in php.ini<a href="#phpini">*</a>.';
  86. }
  87. if (ini_get('register_globals')) {
  88. $phpini = true;
  89. $minorProblems[] = 'Set <strong>register_globals</strong> to <strong>off</strong> in php.ini<a href="#phpini">*</a>.';
  90. }
  91. if (ini_get('session.auto_start')) {
  92. $phpini = true;
  93. $minorProblems[] = 'Set <strong>session.auto_start</strong> to <strong>off</strong> in php.ini<a href="#phpini">*</a>.';
  94. }
  95. ?>
  96. <!DOCTYPE html>
  97. <html>
  98. <head>
  99. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  100. <link href="bundles/sensiodistribution/webconfigurator/css/install.css" rel="stylesheet" type="text/css" media="all" />
  101. <title>Symfony Configuration</title>
  102. </head>
  103. <body>
  104. <div id="symfony-wrapper">
  105. <div id="symfony-content">
  106. <div class="symfony-blocks-install">
  107. <div class="symfony-block-logo">
  108. <img src="bundles/sensiodistribution/webconfigurator/images/logo-big.gif" alt="sf_symfony" />
  109. </div>
  110. <div class="symfony-block-content">
  111. <h1>Welcome!</h1>
  112. <p>Welcome to your new Symfony project.</p>
  113. <p>This script will guide you through the basic configuration of your project. You can also do the same by editing the <strong>app/config/parameters.ini</strong> file directly.</p>
  114. <?php if (count($majorProblems)): ?>
  115. <h2>
  116. <span><?php echo count($majorProblems) ?> Major problems</span>
  117. </h2>
  118. <p>Major problems have been detected and <strong>must</strong> be fixed before continuing :</p>
  119. <ol>
  120. <?php foreach ($majorProblems as $problem): ?>
  121. <li><?php echo $problem; ?></li>
  122. <?php endforeach ?>
  123. </ol>
  124. <?php endif ?>
  125. <?php if (count($minorProblems)): ?>
  126. <h2>Recommendations</h2>
  127. <p>
  128. <?php if ($majorProblems): ?>
  129. Additionally, to
  130. <?php else: ?>
  131. To<?php endif; ?>
  132. enhance your Symfony experience, its recommended that you fix the following :
  133. </p>
  134. <ol>
  135. <?php foreach ($minorProblems as $problem): ?>
  136. <li><?php echo $problem; ?></li>
  137. <?php endforeach; ?>
  138. </ol>
  139. <?php endif ?>
  140. <?php if ($phpini): ?>
  141. <a id="phpini"></a>
  142. <p>*
  143. <?php if (get_cfg_var('cfg_file_path')): ?>
  144. Changes to the <strong>php.ini</strong> file must be done in "<strong><?php echo get_cfg_var('cfg_file_path') ?></strong>".
  145. <?php else: ?>
  146. To change settings, create a "<strong>php.ini</strong>".
  147. <?php endif; ?>
  148. </p>
  149. </div>
  150. <?php endif; ?>
  151. <ul class="symfony-install-continue">
  152. <?php if (!count($majorProblems)): ?>
  153. <li><a href="app_dev.php/_configurator/">Configure your Symfony Application online</a></li>
  154. <li><a href="app_dev.php/">Bypass configuration and go to the Welcome page</a></li>
  155. <?php endif ?>
  156. <li><a href="config.php">Re-check configuration</a></li>
  157. </ul>
  158. </div>
  159. </div>
  160. </div>
  161. <div class="version">Symfony Standard Edition</div>
  162. </body>
  163. </html>