echo_title("Optional checks"); check(class_exists('DomDocument'), 'Checking that the PHP-XML module is installed', 'Install and enable the php-xml module', false); check(defined('LIBXML_COMPACT'), 'Checking that the libxml version is at least 2.6.21', 'Upgrade your php-xml module with a newer libxml', false); check(function_exists('token_get_all'), 'Checking that the token_get_all() function is available', 'Install and enable the Tokenizer extension (highly recommended)', false); check(function_exists('mb_strlen'), 'Checking that the mb_strlen() function is available', 'Install and enable the mbstring extension', false); check(function_exists('iconv'), 'Checking that the iconv() function is available', 'Install and enable the iconv extension', false); check(function_exists('utf8_decode'), 'Checking that the utf8_decode() is available', 'Install and enable the XML extension', false); check(function_exists('posix_isatty'), 'Checking that the posix_isatty() is available', 'Install and enable the php_posix extension (used to colorized the CLI output)', false); check(class_exists('Locale'), 'Checking that the intl extension is available', 'Install and enable the intl extension (used for validators)', false); $accelerator = function_exists('apc_store') && ini_get('apc.enabled') || function_exists('eaccelerator_put') && ini_get('eaccelerator.enable') || function_exists('xcache_set'); check($accelerator, 'Checking that a PHP accelerator is installed', 'Install a PHP accelerator like APC (highly recommended)', false); check(!ini_get('short_open_tag'), 'Checking that php.ini has short_open_tag set to off', 'Set short_open_tag to off in php.ini', false); check(!ini_get('magic_quotes_gpc'), 'Checking that php.ini has magic_quotes_gpc set to off', 'Set magic_quotes_gpc to off in php.ini', false); check(!ini_get('register_globals'), 'Checking that php.ini has register_globals set to off', 'Set register_globals to off in php.ini', false); check(!ini_get('session.auto_start'), 'Checking that php.ini has session.auto_start set to off', 'Set session.auto_start to off in php.ini', false); echo_title("Optional checks (Doctrine)"); check(class_exists('PDO'), 'Checking that PDO is installed', 'Install PDO (mandatory for Doctrine)', false); if (class_exists('PDO')) { $drivers = PDO::getAvailableDrivers(); check(count($drivers), 'Checking that PDO has some drivers installed: ' . implode(', ', $drivers), 'Install PDO drivers (mandatory for Doctrine)'); } if (!is_cli()) { echo '</body></html>'; } /** * Checks a configuration. */ function check($boolean, $message, $help = '', $fatal = false) { if (is_cli()) { echo $boolean ? " OK " : sprintf("\n\n[[%s]] ", $fatal ? ' ERROR ' : 'WARNING');
echo "* than the one used with your web server.\n"; if ('\\' == DIRECTORY_SEPARATOR) { echo "* (especially on the Windows platform)\n"; } echo "* To be on the safe side, please also launch the requirements check\n"; echo "* from your web server using the web/config.php script.\n"; echo_title('Mandatory requirements'); $checkPassed = true; foreach ($symfonyRequirements->getRequirements() as $req) { /** @var $req Requirement */ echo_requirement($req); if (!$req->isFulfilled()) { $checkPassed = false; } } echo_title('Optional recommendations'); foreach ($symfonyRequirements->getRecommendations() as $req) { echo_requirement($req); } exit($checkPassed ? 0 : 1); /** * Prints a Requirement instance */ function echo_requirement(Requirement $requirement) { $result = $requirement->isFulfilled() ? 'OK' : ($requirement->isOptional() ? 'WARNING' : 'ERROR'); echo ' ' . str_pad($result, 9); echo $requirement->getTestMessage() . "\n"; if (!$requirement->isFulfilled()) { echo sprintf(" %s\n\n", $requirement->getHelpText()); }
$messages['warning'][] = $helpText; } else { echo_style('green', '.'); } } if ($checkPassed) { echo_block('success', 'OK', 'Your system is ready to run Symfony2 projects'); } else { echo_block('error', 'ERROR', 'Your system is not ready to run Symfony2 projects'); echo_title('Fix the following mandatory requirements', 'red'); foreach ($messages['error'] as $helpText) { echo ' * ' . $helpText . PHP_EOL; } } if (!empty($messages['warning'])) { echo_title('Optional recommendations to improve your setup', 'yellow'); foreach ($messages['warning'] as $helpText) { echo ' * ' . $helpText . PHP_EOL; } } echo PHP_EOL; echo_style('title', 'Note'); echo ' The command console could use a different php.ini file' . PHP_EOL; echo_style('title', '~~~~'); echo ' than the one used with your web server. To be on the' . PHP_EOL; echo ' safe side, please check the requirements from your web' . PHP_EOL; echo ' server using the '; echo_style('yellow', 'web/config.php'); echo ' script.' . PHP_EOL; echo PHP_EOL; exit($checkPassed ? 0 : 1);
$utf8 = function_exists('mb_strlen'); check(function_exists('mb_strlen'), 'Checking that the mb_strlen() function is available', 'Install and enable the mbstring extension', false); if ($utf8) { echo_title("SINCE YOU HAVE MB_STRLEN, YOU *MUST* ALSO HAVE THE FOLLOWING"); } else { echo_title("NOTE: IF YOU ENABLE MB_STRLEN YOU *MUST* ALSO HAVE THE FOLLOWING OR APOSTROPHE WILL NOT WORK PROPERLY"); } check(function_exists('iconv'), 'Checking that the iconv() function is available', 'Install and enable the iconv extension', $utf8); check(function_exists('utf8_decode'), 'Checking that the utf8_decode() is available', 'Install and enable the XML extension', $utf8); check(preg_match('/[\\p{N}]+/u', '5'), 'Checking that Unicode properties really work in PCRE', 'rebuild PHP with its built-in PCRE library, or fix your system PCRE library to include Unicode properties support.', $utf8); echo_title("Optional Items"); check(function_exists('posix_isatty'), 'Checking that the posix_isatty() is available', 'Install and enable the php_posix extension (used to colorize the CLI output)', false); check(!ini_get('magic_quotes_gpc'), 'Checking that php.ini has magic_quotes_gpc set to off', 'Set magic_quotes_gpc to off in php.ini', false); check(!ini_get('register_globals'), 'Checking that php.ini has register_globals set to off', 'Set register_globals to off in php.ini', false); check(!ini_get('session.auto_start'), 'Checking that php.ini has session.auto_start set to off', 'Set session.auto_start to off in php.ini', false); echo_title('Graphics conversion utility checks (may fail if your install dir is nonstandard)'); check(strlen(`which pnmtopng`), 'Checking that netpbm is installed for lower-overhead image conversion', 'Install the netpbm utilities', false); $accelerator = function_exists('apc_store') && ini_get('apc.enabled') || function_exists('eaccelerator_put') && ini_get('eaccelerator.enable') || function_exists('xcache_set'); check($accelerator, 'Checking that that a PHP accelerator is installed', 'Install a PHP accelerator like APC (performance will NOT be acceptable without one)', false); if (!is_cli()) { echo '</body></html>'; } /** * Checks a configuration. */ function check($boolean, $message, $help = '', $fatal = false) { if (is_cli()) { echo $boolean ? " OK " : sprintf("\n\n[[%s]] ", $fatal ? ' ERROR ' : 'WARNING'); echo sprintf("{$message}%s\n", $boolean ? '' : ': FAILED'); if (!$boolean) {
echo_title("Mandatory requirements"); check($_SERVER['SERVER_NAME'], sprintf('Checking that the SERVER_NAME is set : it is %s', $_SERVER['SERVER_NAME']), 'There is no server name defined', true); check(version_compare(phpversion(), '5.2.0', '>='), sprintf('Checking that PHP version is at least 5.2.2 (%s installed)', phpversion()), 'Install PHP 5.3.1 or newer (current version is ' . phpversion(), true); check(ini_get('date.timezone'), 'Checking that the "date.timezone" setting is set', 'Set the "date.timezone" setting in php.ini (like Europe/Paris)', true); // warnings echo_title("Optional checks"); check(class_exists('DomDocument'), 'Checking that the PHP-XML module is installed', 'Install the php-xml module', false); check(function_exists('token_get_all'), 'Checking that the token_get_all() function is available', 'Install token_get_all() function (highly recommended)', false); check(function_exists('mb_strlen'), 'Checking that the mb_strlen() function is available', 'Install mb_strlen() function', false); check(function_exists('iconv'), 'Checking that the iconv() function is available', 'Install iconv() function', false); check(function_exists('utf8_decode'), 'Checking that the utf8_decode() is available', 'Install utf8_decode() function', false); check(!ini_get('short_open_tag'), 'Checking that php.ini has short_open_tag set to off', 'Set short_open_tag to off in php.ini', false); check(!ini_get('magic_quotes_gpc'), 'Checking that php.ini has magic_quotes_gpc set to off', 'Set magic_quotes_gpc to off in php.ini', false); check(!ini_get('register_globals'), 'Checking that php.ini has register_globals set to off', 'Set register_globals to off in php.ini', false); check(!ini_get('session.auto_start'), 'Checking that php.ini has session.auto_start set to off', 'Set session.auto_start to off in php.ini', false); echo_title("Optional checks (Database)"); check(class_exists('PDO'), 'Checking that PDO is installed', 'Install PDO (mandatory for Propel and Doctrine)', false); if (class_exists('PDO')) { $drivers = PDO::getAvailableDrivers(); check(count($drivers), 'Checking that PDO has some drivers installed: ' . implode(', ', $drivers), 'Install PDO drivers (mandatory for Propel and Doctrine)'); } check(class_exists('XSLTProcessor'), 'Checking that XSL module is installed', 'Install the XSL module (recommended for Propel)', false); check(class_exists('mysqli'), 'Checking that Mysqli is installed', 'Install mysqli (useful for database management)', false); function is_cli() { return !isset($_SERVER['HTTP_HOST']); } function check($boolean, $message, $help = '', $fatal = false) { if (is_cli()) { echo $boolean ? " OK " : sprintf("\n\n[[%s]] ", $fatal ? ' ERROR ' : 'WARNING');
check(is_writable(__DIR__ . '/../hello/logs'), sprintf('Checking that the logs/ directory is writable'), 'Change the permissions of the hello/logs/ directory so that the web server can write in it', true); // warnings echo_title("Optional checks"); check(class_exists('DomDocument'), 'Checking that the PHP-XML module is installed', 'Install and enable the php-xml module', false); check(function_exists('token_get_all'), 'Checking that the token_get_all() function is available', 'Install and enable the Tokenizer extension (highly recommended)', false); check(function_exists('mb_strlen'), 'Checking that the mb_strlen() function is available', 'Install and enable the mbstring extension', false); check(function_exists('iconv'), 'Checking that the iconv() function is available', 'Install and enable the iconv extension', false); check(function_exists('utf8_decode'), 'Checking that the utf8_decode() is available', 'Install and enable the XML extension', false); check(function_exists('posix_isatty'), 'Checking that the posix_isatty() is available', 'Install and enable the php_posix extension (used to colorized the CLI output)', false); $accelerator = function_exists('apc_store') && ini_get('apc.enabled') || function_exists('eaccelerator_put') && ini_get('eaccelerator.enable') || function_exists('xcache_set'); check($accelerator, 'Checking that that a PHP accelerator is installed', 'Install a PHP accelerator like APC (highly recommended)', false); check(!ini_get('short_open_tag'), 'Checking that php.ini has short_open_tag set to off', 'Set short_open_tag to off in php.ini', false); check(!ini_get('magic_quotes_gpc'), 'Checking that php.ini has magic_quotes_gpc set to off', 'Set magic_quotes_gpc to off in php.ini', false); check(!ini_get('register_globals'), 'Checking that php.ini has register_globals set to off', 'Set register_globals to off in php.ini', false); check(!ini_get('session.auto_start'), 'Checking that php.ini has session.auto_start set to off', 'Set session.auto_start to off in php.ini', false); echo_title("Optional checks (Propel/Doctrine)"); check(class_exists('PDO'), 'Checking that PDO is installed', 'Install PDO (mandatory for Propel and Doctrine)', false); if (class_exists('PDO')) { $drivers = PDO::getAvailableDrivers(); check(count($drivers), 'Checking that PDO has some drivers installed: ' . implode(', ', $drivers), 'Install PDO drivers (mandatory for Propel and Doctrine)'); } check(class_exists('XSLTProcessor'), 'Checking that XSL module is installed', 'Install the XSL module (recommended for Propel)', false); if (!is_cli()) { echo '</body></html>'; } /** * Checks a configuration. */ function check($boolean, $message, $help = '', $fatal = false) { if (is_cli()) {
echo "* *\n"; echo "* Symfony requirements check *\n"; echo "* *\n"; echo "********************************\n\n"; echo sprintf("php.ini used by PHP: %s\n\n", $iniPath); echo "** WARNING **\n"; echo "* The PHP CLI can use a different php.ini file\n"; echo "* than the one used with your web server.\n"; if ('\\' == DIRECTORY_SEPARATOR) { echo "* (especially on the Windows platform)\n"; } echo "* If this is the case, please ALSO launch this\n"; echo "* utility from your web server.\n"; echo "** WARNING **\n"; // mandatory echo_title("Mandatory requirements"); check(version_compare(phpversion(), '5.3.2', '>='), sprintf('Checking that PHP version is at least 5.3.2 (%s installed)', phpversion()), 'Install PHP 5.3.2 or newer (current version is ' . phpversion(), true); check(ini_get('date.timezone'), 'Checking that the "date.timezone" setting is set', 'Set the "date.timezone" setting in php.ini (like Europe/Paris)', true); check(is_writable(__DIR__ . '/../app/cache'), sprintf('Checking that app/cache/ directory is writable'), 'Change the permissions of the app/cache/ directory so that the web server can write in it', true); check(is_writable(__DIR__ . '/../app/logs'), sprintf('Checking that the app/logs/ directory is writable'), 'Change the permissions of the app/logs/ directory so that the web server can write in it', true); check(function_exists('json_encode'), 'Checking that the json_encode() is available', 'Install and enable the json extension', true); check(class_exists('SQLite3') || in_array('sqlite', PDO::getAvailableDrivers()), 'Checking that the SQLite3 or PDO_SQLite extension is available', 'Install and enable the SQLite3 or PDO_SQLite extension.', true); check(function_exists('session_start'), 'Checking that the session_start() is available', 'Install and enable the session extension', true); check(function_exists('ctype_alpha'), 'Checking that the ctype_alpha() is available', 'Install and enable the ctype extension', true); /** * Checks a configuration. */ function check($boolean, $message, $help = '', $fatal = false) { echo $boolean ? " OK " : sprintf("\n\n[[%s]] ", $fatal ? ' ERROR ' : 'WARNING'); echo sprintf("{$message}%s\n", $boolean ? '' : ': FAILED');
?> "> <meta name="description" content="<?php echo get_description(); ?> "> <?php if (is_single()) { ?> <meta name="robots" content="nofollow"> <?php } ?> <meta name="viewport" content="width=device-width, initial-scale=1"> <title><?php echo_title(); ?> </title> <!--[if lt IE 8]> <script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script> <script src="//cdn.bootcss.com/html5shiv/r29/html5.min.js"></script> <![endif]--> <?php $shortcutIcon = get_option('web_shortcut_icon'); if (!empty($shortcutIcon)) { ?> <!-- 网站图标 --> <link rel="shortcut icon" href="<?php echo $shortcutIcon; ?> ">
function getConfig() { if (!($iniPath = get_cfg_var('cfg_file_path'))) { $iniPath = '警告: 未找到配置文件 php.ini'; } echo sprintf("php.ini 文件位置: %s<br><br>", $iniPath); if ('\\' == DIRECTORY_SEPARATOR) { echo "* (当前系统: Windows)<br>"; } // mandatory echo_title("核心配置"); check(version_compare(phpversion(), '5.3.2', '>='), sprintf(' PHP 版本 5.3.2及以上 (当前安装 %s )', phpversion()), '支持 PHP 5.3.2 及以上版本 (当前版本 ' . phpversion(), true); check(ini_get('date.timezone'), '"date.timezone" 已配置', '请在php.ini中配置 "date.timezone" (如:Europe/Paris)', true); check(is_writable(__DIR__ . '/../app/cache'), sprintf(' app/cache/ 目录可写'), '请更改目录 app/cache/ 的权限为可写', true); check(is_writable(__DIR__ . '/../app/logs'), sprintf(' app/logs/ 目录可写'), '请更改目录 app/logs/ 的权限为可写', true); check(function_exists('json_encode'), 'json_encode() 功能函数有效', '需要安装 json 扩展', true); check(class_exists('SQLite3') || in_array('sqlite', PDO::getAvailableDrivers()), 'SQLite3 or PDO_SQLite 扩展已安装', '需要安装 SQLite3 or PDO_SQLite 扩展.', true); check(function_exists('session_start'), 'session_start() 功能函数有效', '需要安装 session 扩展', true); // warnings echo_title("Optional checks"); check(class_exists('DomDocument'), 'PHP-XML 模块已安装', '需要安装 php-xml 模块', false); check(function_exists('token_get_all'), ' token_get_all() 功能函数有效', '需要安装 Tokenizer 扩展', false); check(function_exists('mb_strlen'), ' mb_strlen() 功能函数有效', '需要安装 mbstring 扩展', false); check(function_exists('iconv'), 'iconv() 功能函数有效', '需要安装 iconv 扩展', false); check(function_exists('utf8_decode'), 'utf8_decode()功能函数有效', '需要安装 XML 扩展', false); check(function_exists('pcntl_fork'), '多纯程功能有效', '需要安装 maintainer-zts 扩展', true); echo_title("Doctrine配置项检查"); check(class_exists('PDO'), ' PDO 已成功安装', '安装PDO(必须)', true); if (class_exists('PDO')) { $drivers = PDO::getAvailableDrivers(); check(count($drivers), ' PDO 已安装驱动: ' . implode(', ', $drivers), '安装 PDO 驱动 (必须)'); } echo_title("Memcache配置项检查"); check(class_exists('Memcache'), ' Memcache 安装', '安装Memcache(必须)', true); echo_title("Mongo配置项检查"); check(class_exists('Mongo'), ' Mongo 安装', '安装Mongo(必须)', true); echo_title("imagick配置项检查"); check(class_exists('Imagick'), ' imagick 安装', '安装imagick(必须)', true); echo_title("ffmpeg配置项检查"); check(extension_loaded('ffmpeg'), ' ffmpeg 安装', '安装ffmpeg(建议)', false); echo_title("mcrypt配置项检查"); check(function_exists('mcrypt_cbc'), ' mcrypt 安装', '安装mcrypt(必须)', true); echo_title("ZipArchive配置项检查"); check(class_exists('ZipArchive'), ' ZipArchive 安装', '安装ZipArchive(必须)', true); echo_title("Soap配置项检查"); check(class_exists('SoapClient'), ' SoapClient 安装', '可能需要安装SoapClient', false); echo_title("LDAP配置项检查"); check(function_exists('ldap_connect'), ' LDAP 安装', '可能需要安装LDAP', false); echo_title("系统参数配置项检查"); $path = __DIR__ . '/../app/config/parameters.ini'; echo "parameters文件位置:" . (file_exists($path) ? $path : "<strong style=\\'color:red\\'>ERROR </strong>"); echo "<br> *** 完整的配置信息参考<a target=_blank href='../../a.php'><strong style='color:red'>phpinfo</strong></a> ***<br>"; }
REQUIREMENTS CHECK</h1> EOF; echo sprintf("<p><small>php.ini used by PHP: %s</small></p>", get_ini_path()); } // mandatory echo_title("Mandatory requirements"); check(version_compare(phpversion(), '5.3.1', '>='), sprintf('Checking that PHP version is at least 5.3.1 (%s installed)', phpversion()), 'Install PHP 5.3.1 or newer (current version is ' . phpversion(), true); check(ini_get('date.timezone'), 'Checking that the "date.timezone" setting is set', 'Set the "date.timezone" setting in php.ini (like Europe/Paris)', true); check(is_writable(__DIR__ . '/../lichess/cache'), sprintf('Checking that cache/ directory is writable'), 'Change the permissions of the lichess/cache/ directory so that the web server can write in it', true); check(is_writable(__DIR__ . '/../lichess/logs'), sprintf('Checking that the logs/ directory is writable'), 'Change the permissions of the lichess/logs/ directory so that the web server can write in it', true); $accelerator = function_exists('apc_store') && ini_get('apc.enabled'); check($accelerator, 'Checking that APC is installed', 'Install APC', true); $mongo = class_exists('Mongo'); check($mongo, 'Checking that MongoDB is installed', 'Install MongoDB', true); // warnings echo_title("Optional checks"); check(class_exists('DomDocument'), 'Checking that the PHP-XML module is installed', 'Install and enable the php-xml module', false); check(function_exists('token_get_all'), 'Checking that the token_get_all() function is available', 'Install and enable the Tokenizer extension (highly recommended)', false); check(function_exists('mb_strlen'), 'Checking that the mb_strlen() function is available', 'Install and enable the mbstring extension', false); check(function_exists('iconv'), 'Checking that the iconv() function is available', 'Install and enable the iconv extension', false); check(function_exists('utf8_decode'), 'Checking that the utf8_decode() is available', 'Install and enable the XML extension', false); check(function_exists('posix_isatty'), 'Checking that the posix_isatty() is available', 'Install and enable the php_posix extension (used to colorized the CLI output)', false); check(!ini_get('short_open_tag'), 'Checking that php.ini has short_open_tag set to off', 'Set short_open_tag to off in php.ini', false); check(!ini_get('magic_quotes_gpc'), 'Checking that php.ini has magic_quotes_gpc set to off', 'Set magic_quotes_gpc to off in php.ini', false); check(!ini_get('register_globals'), 'Checking that php.ini has register_globals set to off', 'Set register_globals to off in php.ini', false); check(!ini_get('session.auto_start'), 'Checking that php.ini has session.auto_start set to off', 'Set session.auto_start to off in php.ini', false); if (!is_cli()) { echo '</body></html>'; } /** * Checks a configuration.