~fabiocbalbuquerque/sahana-agasti/web-services

« back to all changes in this revision

Viewing changes to check.php

  • Committer: Clayton Kramer
  • Date: 2011-06-02 20:32:55 UTC
  • mto: (1.26.1 push-trunk) (7.1.1 mayon)
  • mto: This revision was merged to the branch mainline in revision 17.
  • Revision ID: clayton.kramer@mail.cuny.edu-20110602203255-jibrhvvu4193e0sa
Staff import working. Still needs to be hooked to indexer.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 and enable the php-xml module (required by Propel)', false);
 
81
check(class_exists('XSLTProcessor'), 'XSL module is installed', 'Install and enable the XSL module (recommended for Propel)', false);
 
82
check(function_exists('token_get_all'), 'The token_get_all() function is available', 'Install and enable the Tokenizer extension (highly recommended)', false);
 
83
check(function_exists('mb_strlen'), 'The mb_strlen() function is available', 'Install and enable the mbstring extension', false);
 
84
check(function_exists('iconv'), 'The iconv() function is available', 'Install and enable the iconv extension', false);
 
85
check(function_exists('utf8_decode'), 'The utf8_decode() is available', 'Install and enable the XML extension', false);
 
86
check(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
;
 
95
check($accelerator, 'A PHP accelerator is installed', 'Install a PHP accelerator like APC (highly recommended)', false);
 
96
 
 
97
check(!ini_get('short_open_tag'), 'php.ini has short_open_tag set to off', 'Set it to off in php.ini', false);
 
98
check(!ini_get('magic_quotes_gpc'), 'php.ini has magic_quotes_gpc set to off', 'Set it to off in php.ini', false);
 
99
check(!ini_get('register_globals'), 'php.ini has register_globals set to off', 'Set it to off in php.ini', false);
 
100
check(!ini_get('session.auto_start'), 'php.ini has session.auto_start set to off', 'Set it to off in php.ini', false);
 
101
 
 
102
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);
 
103
 
 
104
if (!is_cli())
 
105
{
 
106
  echo '</pre></body></html>';
 
107
}