PageRenderTime 21ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/pear/data/symfony/bin/check_configuration.php

https://gitlab.com/klausmig/InformationRetrievalSystem
PHP | 106 lines | 88 code | 10 blank | 8 comment | 10 complexity | 055a83191178e47760463616cf130a28 MD5 | raw file
  1. <?php
  2. function is_cli()
  3. {
  4. return !isset($_SERVER['HTTP_HOST']);
  5. }
  6. /**
  7. * Checks a configuration.
  8. */
  9. function check($boolean, $message, $help = '', $fatal = false)
  10. {
  11. echo $boolean ? " OK " : sprintf("[[%s]] ", $fatal ? ' ERROR ' : 'WARNING');
  12. echo sprintf("$message%s\n", $boolean ? '' : ': FAILED');
  13. if (!$boolean)
  14. {
  15. echo " *** $help ***\n";
  16. if ($fatal)
  17. {
  18. die("You must fix this problem before resuming the check.\n");
  19. }
  20. }
  21. }
  22. /**
  23. * Gets the php.ini path used by the current PHP interpretor.
  24. *
  25. * @return string the php.ini path
  26. */
  27. function get_ini_path()
  28. {
  29. if ($path = get_cfg_var('cfg_file_path'))
  30. {
  31. return $path;
  32. }
  33. return 'WARNING: not using a php.ini file';
  34. }
  35. if (!is_cli())
  36. {
  37. echo '<html><body><pre>';
  38. }
  39. echo "********************************\n";
  40. echo "* *\n";
  41. echo "* symfony requirements check *\n";
  42. echo "* *\n";
  43. echo "********************************\n\n";
  44. echo sprintf("php.ini used by PHP: %s\n\n", get_ini_path());
  45. if (is_cli())
  46. {
  47. echo "** WARNING **\n";
  48. echo "* The PHP CLI can use a different php.ini file\n";
  49. echo "* than the one used with your web server.\n";
  50. if ('\\' == DIRECTORY_SEPARATOR)
  51. {
  52. echo "* (especially on the Windows platform)\n";
  53. }
  54. echo "* If this is the case, please launch this\n";
  55. echo "* utility from your web server.\n";
  56. echo "** WARNING **\n";
  57. }
  58. // mandatory
  59. echo "\n** Mandatory requirements **\n\n";
  60. check(version_compare(phpversion(), '5.2.4', '>='), 'PHP version is at least 5.2.4', 'Current version is '.phpversion(), true);
  61. // warnings
  62. echo "\n** Optional checks **\n\n";
  63. check(class_exists('PDO'), 'PDO is installed', 'Install PDO (mandatory for Propel and Doctrine)', false);
  64. if (class_exists('PDO'))
  65. {
  66. $drivers = PDO::getAvailableDrivers();
  67. check(count($drivers), 'PDO has some drivers installed: '.implode(', ', $drivers), 'Install PDO drivers (mandatory for Propel and Doctrine)');
  68. }
  69. check(class_exists('DomDocument'), 'PHP-XML module is installed', 'Install the php-xml module (required by Propel)', false);
  70. check(class_exists('XSLTProcessor'), 'XSL module is installed', 'Install the XSL module (recommended for Propel)', false);
  71. check(function_exists('token_get_all'), 'The token_get_all() function is available', 'Install token_get_all() function (highly recommended)', false);
  72. check(function_exists('mb_strlen'), 'The mb_strlen() function is available', 'Install mb_strlen() function', false);
  73. check(function_exists('iconv'), 'The iconv() function is available', 'Install iconv() function', false);
  74. check(function_exists('utf8_decode'), 'The utf8_decode() is available', 'Install utf8_decode() function', false);
  75. $accelerator =
  76. (function_exists('apc_store') && ini_get('apc.enabled'))
  77. ||
  78. function_exists('eaccelerator_put') && ini_get('eaccelerator.enable')
  79. ||
  80. function_exists('xcache_set')
  81. ;
  82. check($accelerator, 'A PHP accelerator is installed', 'Install a PHP accelerator like APC (highly recommended)', false);
  83. check(!ini_get('short_open_tag'), 'php.ini has short_open_tag set to off', 'Set it to off in php.ini', false);
  84. check(!ini_get('magic_quotes_gpc'), 'php.ini has magic_quotes_gpc set to off', 'Set it to off in php.ini', false);
  85. check(!ini_get('register_globals'), 'php.ini has register_globals set to off', 'Set it to off in php.ini', false);
  86. check(!ini_get('session.auto_start'), 'php.ini has session.auto_start set to off', 'Set it to off in php.ini', false);
  87. check(version_compare(phpversion(), '5.2.9', '!='), 'PHP version is not 5.2.9', 'PHP 5.2.9 broke array_unique() and sfToolkit::arrayDeepMerge(). Use 5.2.10 instead [Ticket #6211]', false);
  88. if (!is_cli())
  89. {
  90. echo '</pre></body></html>';
  91. }