4
* Yii Requirement Checker script
6
* This script will check if your system meets the requirements for running
7
* Yii-powered Web applications.
9
* @author Qiang Xue <qiang.xue@gmail.com>
10
* @link http://www.yiiframework.com/
11
* @copyright Copyright © 2008-2011 Yii Software LLC
12
* @license http://www.yiiframework.com/license/
13
* @version $Id: index.php 2800 2011-01-01 19:36:52Z qiang.xue $
18
* @var array List of requirements (name, required or not, result, used by, memo)
22
t('yii','PHP version'),
24
version_compare(PHP_VERSION,"5.1.0",">="),
25
'<a href="http://www.yiiframework.com">Yii Framework</a>',
26
t('yii','PHP 5.1.0 or higher is required.')),
28
t('yii','$_SERVER variable'),
30
($message=checkServerVar()) === '',
31
'<a href="http://www.yiiframework.com">Yii Framework</a>',
34
t('yii','Reflection extension'),
36
class_exists('Reflection',false),
37
'<a href="http://www.yiiframework.com">Yii Framework</a>',
40
t('yii','PCRE extension'),
42
extension_loaded("pcre"),
43
'<a href="http://www.yiiframework.com">Yii Framework</a>',
46
t('yii','SPL extension'),
48
extension_loaded("SPL"),
49
'<a href="http://www.yiiframework.com">Yii Framework</a>',
52
t('yii','DOM extension'),
54
class_exists("DOMDocument",false),
55
'<a href="http://www.yiiframework.com/doc/api/CHtmlPurifier">CHtmlPurifier</a>, <a href="http://www.yiiframework.com/doc/api/CWsdlGenerator">CWsdlGenerator</a>',
58
t('yii','PDO extension'),
60
extension_loaded('pdo'),
61
t('yii','All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>'),
64
t('yii','PDO SQLite extension'),
66
extension_loaded('pdo_sqlite'),
67
t('yii','All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>'),
68
t('yii','This is required if you are using SQLite database.')),
70
t('yii','PDO MySQL extension'),
72
extension_loaded('pdo_mysql'),
73
t('yii','All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>'),
74
t('yii','This is required if you are using MySQL database.')),
76
t('yii','PDO PostgreSQL extension'),
78
extension_loaded('pdo_pgsql'),
79
t('yii','All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>'),
80
t('yii','This is required if you are using PostgreSQL database.')),
82
t('yii','Memcache extension'),
84
extension_loaded("memcache"),
85
'<a href="http://www.yiiframework.com/doc/api/CMemCache">CMemCache</a>',
88
t('yii','APC extension'),
90
extension_loaded("apc"),
91
'<a href="http://www.yiiframework.com/doc/api/CApcCache">CApcCache</a>',
94
t('yii','Mcrypt extension'),
96
extension_loaded("mcrypt"),
97
'<a href="http://www.yiiframework.com/doc/api/CSecurityManager">CSecurityManager</a>',
98
t('yii','This is required by encrypt and decrypt methods.')),
100
t('yii','SOAP extension'),
102
extension_loaded("soap"),
103
'<a href="http://www.yiiframework.com/doc/api/CWebService">CWebService</a>, <a href="http://www.yiiframework.com/doc/api/CWebServiceAction">CWebServiceAction</a>',
106
t('yii','GD extension with<br />FreeType support'),
108
($message=checkGD()) === '',
109
//extension_loaded('gd'),
110
'<a href="http://www.yiiframework.com/doc/api/CCaptchaAction">CCaptchaAction</a>',
114
function checkServerVar()
116
$vars=array('HTTP_HOST','SERVER_NAME','SERVER_PORT','SCRIPT_NAME','SCRIPT_FILENAME','PHP_SELF','HTTP_ACCEPT','HTTP_USER_AGENT');
118
foreach($vars as $var)
120
if(!isset($_SERVER[$var]))
124
return t('yii','$_SERVER does not have {vars}.',array('{vars}'=>implode(', ',$missing)));
126
if(realpath($_SERVER["SCRIPT_FILENAME"]) !== realpath(__FILE__))
127
return t('yii','$_SERVER["SCRIPT_FILENAME"] must be the same as the entry script file path.');
129
if(!isset($_SERVER["REQUEST_URI"]) && isset($_SERVER["QUERY_STRING"]))
130
return t('yii','Either $_SERVER["REQUEST_URI"] or $_SERVER["QUERY_STRING"] must exist.');
132
if(!isset($_SERVER["PATH_INFO"]) && strpos($_SERVER["PHP_SELF"],$_SERVER["SCRIPT_NAME"]) !== 0)
133
return t('yii','Unable to determine URL path info. Please make sure $_SERVER["PATH_INFO"] (or $_SERVER["PHP_SELF"] and $_SERVER["SCRIPT_NAME"]) contains proper value.');
140
if(extension_loaded('gd'))
143
if($gdinfo['FreeType Support'])
145
return t('yii','GD installed<br />FreeType support not installed');
147
return t('yii','GD not installed');
150
function getYiiVersion()
152
$coreFile=dirname(__FILE__).'/../framework/YiiBase.php';
153
if(is_file($coreFile))
155
$contents=file_get_contents($coreFile);
157
if(preg_match('/public static function getVersion.*?return \'(.*?)\'/ms',$contents,$matches) > 0)
164
* Returns a localized message according to user preferred language.
165
* @param string message category
166
* @param string message to be translated
167
* @param array parameters to be applied to the translated message
168
* @return string translated message
170
function t($category,$message,$params=array())
174
if($messages === null)
177
if(($lang=getPreferredLanguage()) !== false)
179
$file=dirname(__FILE__)."/messages/$lang/yii.php";
181
$messages=include($file);
188
if(isset($messages[$message]) && $messages[$message] !== '')
189
$message=$messages[$message];
191
return $params !== array() ? strtr($message,$params) : $message;
194
function getPreferredLanguage()
196
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) && ($n=preg_match_all('/([\w\-]+)\s*(;\s*q\s*=\s*(\d*\.\d*))?/',$_SERVER['HTTP_ACCEPT_LANGUAGE'],$matches)) > 0)
199
for($i=0; $i < $n; ++$i)
200
$languages[$matches[1][$i]]=empty($matches[3][$i]) ? 1.0 : floatval($matches[3][$i]);
202
foreach($languages as $language=>$pref)
203
return strtolower(str_replace('-','_',$language));
208
function getServerInfo()
210
$info[]=isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : '';
211
$info[]='<a href="http://www.yiiframework.com/">Yii Framework</a>/'.getYiiVersion();
212
$info[]=@strftime('%Y-%m-%d %H:%M',time());
214
return implode(' ',$info);
217
function renderFile($_file_,$_params_=array())
223
$result=1; // 1: all pass, 0: fail, -1: pass with warnings
225
foreach($requirements as $i=>$requirement)
227
if($requirement[1] && !$requirement[2])
229
else if($result > 0 && !$requirement[1] && !$requirement[2])
231
if($requirement[4] === '')
232
$requirements[$i][4]=' ';
235
$lang=getPreferredLanguage();
236
$viewFile=dirname(__FILE__)."/views/$lang/index.php";
237
if(!is_file($viewFile))
238
$viewFile=dirname(__FILE__).'/views/index.php';
240
renderFile($viewFile,array(
241
'requirements'=>$requirements,
243
'serverInfo'=>getServerInfo()));