PageRenderTime 53ms CodeModel.GetById 31ms RepoModel.GetById 0ms app.codeStats 0ms

/web/config.php

https://github.com/nguyennamtien/TaskBoxx
PHP | 182 lines | 152 code | 27 blank | 3 comment | 34 complexity | 44801dfee7aad6cc3df6f98db49ee28b 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. if (!in_array(@$_SERVER['REMOTE_ADDR'], array(
  6. '127.0.0.1',
  7. '::1',
  8. ))) {
  9. header('HTTP/1.0 403 Forbidden');
  10. die('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 (!defined('LIBXML_COMPACT')) {
  37. $minorProblems[] = 'Upgrade your <strong>php-xml</strong> extension with a newer libxml.';
  38. }
  39. if (!((function_exists('apc_store') && ini_get('apc.enabled')) || function_exists('eaccelerator_put') && ini_get('eaccelerator.enable') || function_exists('xcache_set'))) {
  40. $minorProblems[] = 'Install and enable a <strong>PHP accelerator</strong> like APC (highly recommended).';
  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. }
  60. if (!class_exists('SQLite3') && !in_array('sqlite', PDO::getAvailableDrivers())) {
  61. $majorProblems[] = 'Install and enable the <strong>SQLite3</strong> or <strong>PDO_SQLite</strong> extension.';
  62. }
  63. if (!function_exists('json_encode')) {
  64. $majorProblems[] = 'Install and enable the <strong>json</strong> extension.';
  65. }
  66. // php.ini
  67. if (!ini_get('date.timezone')) {
  68. $phpini = true;
  69. $majorProblems[] = 'Set the "<strong>date.timezone</strong>" setting in php.ini<a href="#phpini">*</a> (like Europe/Paris).';
  70. }
  71. if (ini_get('short_open_tag')) {
  72. $phpini = true;
  73. $minorProblems[] = 'Set <strong>short_open_tag</strong> to <strong>off</strong> in php.ini<a href="#phpini">*</a>.';
  74. }
  75. if (ini_get('magic_quotes_gpc')) {
  76. $phpini = true;
  77. $minorProblems[] = 'Set <strong>magic_quotes_gpc</strong> to <strong>off</strong> in php.ini<a href="#phpini">*</a>.';
  78. }
  79. if (ini_get('register_globals')) {
  80. $phpini = true;
  81. $minorProblems[] = 'Set <strong>register_globals</strong> to <strong>off</strong> in php.ini<a href="#phpini">*</a>.';
  82. }
  83. if (ini_get('session.auto_start')) {
  84. $phpini = true;
  85. $minorProblems[] = 'Set <strong>session.auto_start</strong> to <strong>off</strong> in php.ini<a href="#phpini">*</a>.';
  86. }
  87. ?>
  88. <!DOCTYPE html>
  89. <html>
  90. <head>
  91. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  92. <link href="bundles/symfonywebconfigurator/css/install.css" rel="stylesheet" type="text/css" media="all" />
  93. <title>Symfony Configuration</title>
  94. </head>
  95. <body>
  96. <div id="symfony-wrapper">
  97. <div id="symfony-content">
  98. <div class="symfony-blocks-install">
  99. <div class="symfony-block-logo">
  100. <img src="bundles/symfonywebconfigurator/images/logo-big.gif" alt="sf_symfony" />
  101. </div>
  102. <div class="symfony-block-content">
  103. <h1>Welcome!</h1>
  104. <p>Welcome to your new Symfony project.</p>
  105. <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>
  106. <?php if (count($majorProblems)): ?>
  107. <h2>
  108. <span><?php echo count($majorProblems) ?> Major problems</span>
  109. </h2>
  110. <p>Major problems have been detected and <strong>must</strong> be fixed before continuing :</p>
  111. <ol>
  112. <?php foreach ($majorProblems as $problem): ?>
  113. <li><?php echo $problem; ?></li>
  114. <?php endforeach ?>
  115. </ol>
  116. <?php endif ?>
  117. <?php if (count($minorProblems)): ?>
  118. <h2>Recommendations</h2>
  119. <p>
  120. <?php if ($majorProblems): ?>
  121. Additionally, to
  122. <?php else: ?>
  123. To<?php endif; ?>
  124. enhance your Symfony experience, its recommended that you fix the following :
  125. </p>
  126. <ol>
  127. <?php foreach ($minorProblems as $problem): ?>
  128. <li><?php echo $problem; ?></li>
  129. <?php endforeach; ?>
  130. </ol>
  131. <?php endif ?>
  132. <?php if ($phpini): ?>
  133. <a name="phpini"></a>
  134. <p>*
  135. <?php if (get_cfg_var('cfg_file_path')): ?>
  136. Changes to the <strong>php.ini</strong> file must be done in "<strong><?php echo get_cfg_var('cfg_file_path') ?></strong>".
  137. <?php else: ?>
  138. To change settings, create a "<strong>php.ini</strong>".
  139. <?php endif; ?>
  140. </p>
  141. </div>
  142. <?php endif; ?>
  143. <ul class="symfony-install-continue">
  144. <?php if (!count($majorProblems)): ?>
  145. <li><a href="app_dev.php/_configurator/">Configure your Symfony Application online</a></li>
  146. <li><a href="app_dev.php/">Bypass configuration and go to the Welcome page</a></li>
  147. <?php endif ?>
  148. <li><a href="config.php">Re-check configuration</a></li>
  149. </ul>
  150. </div>
  151. </div>
  152. </div>
  153. <div class="version">Symfony Standard Edition v.<?php echo file_get_contents(__DIR__.'/../VERSION') ?></div>
  154. </body>
  155. </html>