Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
function is_cli()
4
{
5
  return !isset($_SERVER['HTTP_HOST']);
6
}
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
 
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
 */
31
function 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
 
41
if (!is_cli())
42
{
43
  echo '<html><body><pre>';
44
}
45
 
46
echo "********************************\n";
47
echo "*                              *\n";
48
echo "*  symfony requirements check  *\n";
49
echo "*                              *\n";
50
echo "********************************\n\n";
51
 
52
echo sprintf("php.ini used by PHP: %s\n\n", get_ini_path());
53
 
54
if (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
69
echo "\n** Mandatory requirements **\n\n";
70
check(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
73
echo "\n** Optional checks **\n\n";
74
check(class_exists('PDO'), 'PDO is installed', 'Install PDO (mandatory for Propel and Doctrine)', false);
75
if (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
}
80
check(class_exists('DomDocument'), 'PHP-XML module is installed', 'Install the php-xml module (required by Propel)', false);
81
check(class_exists('XSLTProcessor'), 'XSL module is installed', 'Install the XSL module (recommended for Propel)', false);
82
check(function_exists('token_get_all'), 'The token_get_all() function is available', 'Install token_get_all() function (highly recommended)', false);
83
check(function_exists('mb_strlen'), 'The mb_strlen() function is available', 'Install mb_strlen() function', false);
84
check(function_exists('iconv'), 'The iconv() function is available', 'Install iconv() function', false);
85
check(function_exists('utf8_decode'), 'The utf8_decode() is available', 'Install utf8_decode() function', false);
86
 
87
$accelerator =
88
  (function_exists('apc_store') && ini_get('apc.enabled'))
89
  ||
90
  function_exists('eaccelerator_put') && ini_get('eaccelerator.enable')
91
  ||
92
  function_exists('xcache_set')
93
;
94
check($accelerator, 'A PHP accelerator is installed', 'Install a PHP accelerator like APC (highly recommended)', false);
95
 
96
check(!ini_get('short_open_tag'), 'php.ini has short_open_tag set to off', 'Set it to off in php.ini', false);
97
check(!ini_get('magic_quotes_gpc'), 'php.ini has magic_quotes_gpc set to off', 'Set it to off in php.ini', false);
98
check(!ini_get('register_globals'), 'php.ini has register_globals set to off', 'Set it to off in php.ini', false);
99
check(!ini_get('session.auto_start'), 'php.ini has session.auto_start set to off', 'Set it to off in php.ini', false);
100
 
101
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);
102
 
103
if (!is_cli())
104
{
105
  echo '</pre></body></html>';
106
}