source: pro-violet-viettel/sourcecode/api.violet.vn/www/check_configuration.php @ 740

Last change on this file since 740 was 289, checked in by dungnv, 11 years ago
File size: 3.9 KB
Line 
1<?php
2
3function is_cli()
4{
5  return !isset($_SERVER['HTTP_HOST']);
6}
7
8/**
9 * Checks a configuration.
10 */
11function 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
16  if (!$boolean)
17  {
18    echo "            *** $help ***\n";
19    if ($fatal)
20    {
21      die("You must fix this problem before resuming the check.\n");
22    }
23  }
24}
25
26/**
27 * Gets the php.ini path used by the current PHP interpretor.
28 *
29 * @return string the php.ini path
30 */
31function get_ini_path()
32{
33  if ($path = get_cfg_var('cfg_file_path'))
34  {
35    return $path;
36  }
37
38  return 'WARNING: not using a php.ini file';
39}
40
41if (!is_cli())
42{
43  echo '<html><body><pre>';
44}
45
46echo "********************************\n";
47echo "*                              *\n";
48echo "*  symfony requirements check  *\n";
49echo "*                              *\n";
50echo "********************************\n\n";
51
52echo sprintf("php.ini used by PHP: %s\n\n", get_ini_path());
53
54if (is_cli())
55{
56  echo "** WARNING **\n";
57  echo "*  The PHP CLI can use a different php.ini file\n";
58  echo "*  than the one used with your web server.\n";
59  if ('\\' == DIRECTORY_SEPARATOR)
60  {
61    echo "*  (especially on the Windows platform)\n";
62  }
63  echo "*  If this is the case, please launch this\n";
64  echo "*  utility from your web server.\n";
65  echo "** WARNING **\n";
66}
67
68// mandatory
69echo "\n** Mandatory requirements **\n\n";
70check(version_compare(phpversion(), '5.2.4', '>='), sprintf('PHP version is at least 5.2.4 (%s)', phpversion()), 'Current version is '.phpversion(), true);
71
72// warnings
73echo "\n** Optional checks **\n\n";
74check(class_exists('PDO'), 'PDO is installed', 'Install PDO (mandatory for Propel and Doctrine)', false);
75if (class_exists('PDO'))
76{
77  $drivers = PDO::getAvailableDrivers();
78  check(count($drivers), 'PDO has some drivers installed: '.implode(', ', $drivers), 'Install PDO drivers (mandatory for Propel and Doctrine)');
79}
80check(class_exists('DomDocument'), 'PHP-XML module is installed', 'Install and enable the php-xml module (required by Propel)', false);
81check(class_exists('XSLTProcessor'), 'XSL module is installed', 'Install and enable the XSL module (recommended for Propel)', false);
82check(function_exists('token_get_all'), 'The token_get_all() function is available', 'Install and enable the Tokenizer extension (highly recommended)', false);
83check(function_exists('mb_strlen'), 'The mb_strlen() function is available', 'Install and enable the mbstring extension', false);
84check(function_exists('iconv'), 'The iconv() function is available', 'Install and enable the iconv extension', false);
85check(function_exists('utf8_decode'), 'The utf8_decode() is available', 'Install and enable the XML extension', false);
86check(function_exists('posix_isatty'), 'The posix_isatty() is available', 'Install and enable the php_posix extension (used to colorized the CLI output)', false);
87
88$accelerator =
89  (function_exists('apc_store') && ini_get('apc.enabled'))
90  ||
91  function_exists('eaccelerator_put') && ini_get('eaccelerator.enable')
92  ||
93  function_exists('xcache_set')
94;
95check($accelerator, 'A PHP accelerator is installed', 'Install a PHP accelerator like APC (highly recommended)', false);
96
97check(!ini_get('short_open_tag'), 'php.ini has short_open_tag set to off', 'Set it to off in php.ini', false);
98check(!ini_get('magic_quotes_gpc'), 'php.ini has magic_quotes_gpc set to off', 'Set it to off in php.ini', false);
99check(!ini_get('register_globals'), 'php.ini has register_globals set to off', 'Set it to off in php.ini', false);
100check(!ini_get('session.auto_start'), 'php.ini has session.auto_start set to off', 'Set it to off in php.ini', false);
101
102check(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);
103
104if (!is_cli())
105{
106  echo '</pre></body></html>';
107}
Note: See TracBrowser for help on using the repository browser.