PageRenderTime 1551ms CodeModel.GetById 30ms RepoModel.GetById 1ms app.codeStats 0ms

/check_configuration.php

http://streeme.googlecode.com/
PHP | 111 lines | 93 code | 10 blank | 8 comment | 10 complexity | 6e7c59c3ba9aaed9339926935f482577 MD5 | raw file
Possible License(s): LGPL-3.0, GPL-2.0, ISC, AGPL-3.0, LGPL-2.1, BSD-3-Clause
  1. <?php
  2. @include( 'HTTP/Download.php' );
  3. @include( dirname( __FILE__ ) . '/lib/vendor/symfony/lib/action/sfActionStack.class.php' );
  4. function is_cli()
  5. {
  6. return !isset($_SERVER['HTTP_HOST']);
  7. }
  8. /**
  9. * Checks a configuration.
  10. */
  11. function check($boolean, $message, $help = '', $fatal = false)
  12. {
  13. echo $boolean ? " OK " : sprintf("[[%s]] ", $fatal ? ' ERROR ' : 'WARNING');
  14. echo sprintf("$message%s\n", $boolean ? '' : ': FAILED');
  15. if (!$boolean)
  16. {
  17. echo " *** $help ***\n";
  18. if ($fatal)
  19. {
  20. die("You must fix this problem before resuming the check.\n");
  21. }
  22. }
  23. }
  24. /**
  25. * Gets the php.ini path used by the current PHP interpretor.
  26. *
  27. * @return string the php.ini path
  28. */
  29. function get_ini_path()
  30. {
  31. if ($path = get_cfg_var('cfg_file_path'))
  32. {
  33. return $path;
  34. }
  35. return 'WARNING: not using a php.ini file';
  36. }
  37. if (!is_cli())
  38. {
  39. echo '<html><body><pre>';
  40. }
  41. echo "********************************\n";
  42. echo "* *\n";
  43. echo "* symfony requirements check *\n";
  44. echo "* *\n";
  45. echo "********************************\n\n";
  46. echo sprintf("php.ini used by PHP: %s\n\n", get_ini_path());
  47. if (is_cli())
  48. {
  49. echo "** WARNING **\n";
  50. echo "* The PHP CLI can use a different php.ini file\n";
  51. echo "* than the one used with your web server.\n";
  52. if ('\\' == DIRECTORY_SEPARATOR)
  53. {
  54. echo "* (especially on the Windows platform)\n";
  55. }
  56. echo "* If this is the case, please launch this\n";
  57. echo "* utility from your web server.\n";
  58. echo "** WARNING **\n";
  59. }
  60. // mandatory
  61. echo "\n** Mandatory requirements **\n\n";
  62. check(version_compare(phpversion(), '5.2.4', '>='), sprintf('PHP version is at least 5.2.4 (%s)', phpversion()), 'Current version is '.phpversion(), true);
  63. check(class_exists('HTTP_Download'), 'PEAR HTTP_Download is Installed', 'Please install HTTP_Download before trying to use the application', true);
  64. check(class_exists('sfActionStack'), 'Symfony is Installed', 'Symfony is missing or has been placed in the wrong folder!', true);
  65. // warnings
  66. echo "\n** Optional checks **\n\n";
  67. check(class_exists('PDO'), 'PDO is installed', 'Install PDO (mandatory for Propel and Doctrine)', false);
  68. if (class_exists('PDO'))
  69. {
  70. $drivers = PDO::getAvailableDrivers();
  71. check(count($drivers), 'PDO has some drivers installed: '.implode(', ', $drivers), 'Install PDO drivers (mandatory for Propel and Doctrine)');
  72. }
  73. check(class_exists('DomDocument'), 'PHP-XML module is installed', 'Install and enable the php-xml module (required by Propel)', false);
  74. check(class_exists('XSLTProcessor'), 'XSL module is installed', 'Install and enable the XSL module (recommended for Propel)', false);
  75. check(function_exists('token_get_all'), 'The token_get_all() function is available', 'Install and enable the Tokenizer extension (highly recommended)', false);
  76. check(function_exists('mb_strlen'), 'The mb_strlen() function is available', 'Install and enable the mbstring extension', false);
  77. check(function_exists('iconv'), 'The iconv() function is available', 'Install and enable the iconv extension', false);
  78. check(function_exists('utf8_decode'), 'The utf8_decode() is available', 'Install and enable the XML extension', false);
  79. check(function_exists('posix_isatty'), 'The posix_isatty() is available', 'Install and enable the php_posix extension (used to colorized the CLI output)', false);
  80. $accelerator =
  81. (function_exists('apc_store') && ini_get('apc.enabled'))
  82. ||
  83. function_exists('eaccelerator_put') && ini_get('eaccelerator.enable')
  84. ||
  85. function_exists('xcache_set')
  86. ;
  87. check($accelerator, 'A PHP accelerator is installed', 'Install a PHP accelerator like APC (highly recommended)', false);
  88. check(!ini_get('short_open_tag'), 'php.ini has short_open_tag set to off', 'Set it to off in php.ini', false);
  89. check(!ini_get('magic_quotes_gpc'), 'php.ini has magic_quotes_gpc set to off', 'Set it to off in php.ini', false);
  90. check(!ini_get('register_globals'), 'php.ini has register_globals set to off', 'Set it to off in php.ini', false);
  91. check(!ini_get('session.auto_start'), 'php.ini has session.auto_start set to off', 'Set it to off in php.ini', false);
  92. 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);
  93. if (!is_cli())
  94. {
  95. echo '</pre></body></html>';
  96. }