PageRenderTime 46ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/symfony2/web/config.php

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