| 1 |
lars |
1 |
<?php
|
|
|
2 |
/**
|
|
|
3 |
* PRADO Requirements Checker script
|
|
|
4 |
*
|
|
|
5 |
* @author Qiang Xue <qiang.xue@gmail.com>
|
|
|
6 |
* @link http://www.pradosoft.com/
|
|
|
7 |
* @copyright Copyright © 2005 PradoSoft
|
|
|
8 |
* @license http://www.pradosoft.com/license/
|
|
|
9 |
* @version $Id: index.php 2085 2007-07-26 12:06:39Z xue $
|
|
|
10 |
* @package prado
|
|
|
11 |
*/
|
|
|
12 |
|
|
|
13 |
/**
|
|
|
14 |
* PRADO Requirements Checker script
|
|
|
15 |
*
|
|
|
16 |
* This script will check if your system meets the requirements for running PRADO.
|
|
|
17 |
* It will check if you are running the right version of PHP, if you included
|
|
|
18 |
* the right libraries and if your php.ini file settings are correct.
|
|
|
19 |
*
|
|
|
20 |
* This script is capable of displaying localized messages.
|
|
|
21 |
* All messages are stored in messages.txt. A localized message file is named as
|
|
|
22 |
* messsages-<language code>.txt, and it will be used when the client browser
|
|
|
23 |
* chooses the corresponding language.
|
|
|
24 |
* The script output uses a template named template.html.
|
|
|
25 |
* Its localized version is stored in template-<language code>.html.
|
|
|
26 |
*/
|
|
|
27 |
|
|
|
28 |
// TO BE CONFIRMED: PHP 5.1.0 has problem with I18N and L10N
|
|
|
29 |
/**
|
|
|
30 |
* @var array List of requirements (required or not, check item, hint)
|
|
|
31 |
*/
|
|
|
32 |
$requirements = array(
|
|
|
33 |
array(
|
|
|
34 |
true,
|
|
|
35 |
version_compare(PHP_VERSION,"5.1.0",">="),
|
|
|
36 |
'PHP version check','PHP 5.1.0 or higher required'),
|
|
|
37 |
array(
|
|
|
38 |
true,
|
|
|
39 |
isset($_SERVER["HTTP_ACCEPT"]),
|
|
|
40 |
'$_SERVER["HTTP_ACCEPT"] check',
|
|
|
41 |
'HTTP_ACCEPT required'),
|
|
|
42 |
array(
|
|
|
43 |
true,
|
|
|
44 |
isset($_SERVER["SCRIPT_FILENAME"]) && realpath($_SERVER["SCRIPT_FILENAME"])===realpath(__FILE__),
|
|
|
45 |
'$_SERVER["SCRIPT_FILENAME"] check',
|
|
|
46 |
'SCRIPT_FILENAME required'),
|
|
|
47 |
array(
|
|
|
48 |
true,
|
|
|
49 |
isset($_SERVER["REQUEST_URI"]) || isset($_SERVER["QUERY_STRING"]),
|
|
|
50 |
'$_SERVER["REQUEST_URI"] check',
|
|
|
51 |
'REQUEST_URI required'),
|
|
|
52 |
array(
|
|
|
53 |
true,
|
|
|
54 |
isset($_SERVER["PATH_INFO"]) || strpos($_SERVER["PHP_SELF"],$_SERVER["SCRIPT_NAME"])===0,
|
|
|
55 |
'$_SERVER["PATH_INFO"] check',
|
|
|
56 |
'PATH_INFO required'),
|
|
|
57 |
array(
|
|
|
58 |
true,
|
|
|
59 |
class_exists('Reflection',false),
|
|
|
60 |
'Reflection extension check',
|
|
|
61 |
'Reflection extension required'),
|
|
|
62 |
array(
|
|
|
63 |
true,
|
|
|
64 |
class_exists("DOMDocument",false),
|
|
|
65 |
'DOM extension check',
|
|
|
66 |
'DOM extension required'),
|
|
|
67 |
array(
|
|
|
68 |
true,
|
|
|
69 |
extension_loaded("SPL"),
|
|
|
70 |
'SPL extension check',
|
|
|
71 |
'SPL extension required'),
|
|
|
72 |
array(
|
|
|
73 |
true,
|
|
|
74 |
extension_loaded("CType"),
|
|
|
75 |
'CType extension check',
|
|
|
76 |
'CType extension required'),
|
|
|
77 |
array(
|
|
|
78 |
true,
|
|
|
79 |
extension_loaded("pcre"),
|
|
|
80 |
'PCRE extension check',
|
|
|
81 |
'PCRE extension required'),
|
|
|
82 |
array(
|
|
|
83 |
false,
|
|
|
84 |
class_exists("PDO",false),
|
|
|
85 |
'PDO extension check',
|
|
|
86 |
'PDO extension optional'),
|
|
|
87 |
array(
|
|
|
88 |
false,
|
|
|
89 |
function_exists("iconv"),
|
|
|
90 |
'ICONV extension check',
|
|
|
91 |
'ICONV extension optional'),
|
|
|
92 |
array(
|
|
|
93 |
false,
|
|
|
94 |
extension_loaded("zlib"),
|
|
|
95 |
'Zlib extension check',
|
|
|
96 |
'Zlib extension optional'),
|
|
|
97 |
array(
|
|
|
98 |
false,
|
|
|
99 |
extension_loaded("sqlite"),
|
|
|
100 |
'SQLite extension check',
|
|
|
101 |
'SQLite extension optional'),
|
|
|
102 |
array(
|
|
|
103 |
false,
|
|
|
104 |
extension_loaded("memcache"),
|
|
|
105 |
'Memcache extension check',
|
|
|
106 |
'Memcache extension optional'),
|
|
|
107 |
array(
|
|
|
108 |
false,
|
|
|
109 |
extension_loaded("apc"),
|
|
|
110 |
'APC extension check',
|
|
|
111 |
'APC extension optional'),
|
|
|
112 |
array(
|
|
|
113 |
false,
|
|
|
114 |
extension_loaded("mcrypt"),
|
|
|
115 |
'Mcrypt extension check',
|
|
|
116 |
'Mcrypt extension optional'),
|
|
|
117 |
array(
|
|
|
118 |
false,
|
|
|
119 |
extension_loaded("xsl"),
|
|
|
120 |
'XSL extension check',
|
|
|
121 |
'XSL extension optional'),
|
|
|
122 |
array(
|
|
|
123 |
false,
|
|
|
124 |
extension_loaded("soap"),
|
|
|
125 |
'SOAP extension check',
|
|
|
126 |
'SOAP extension optional'),
|
|
|
127 |
);
|
|
|
128 |
|
|
|
129 |
$results = "<table class=\"result\">\n";
|
|
|
130 |
$conclusion = 0;
|
|
|
131 |
foreach($requirements as $requirement)
|
|
|
132 |
{
|
|
|
133 |
list($required,$expression,$aspect,$hint)=$requirement;
|
|
|
134 |
//eval('$ret='.$expression.';');
|
|
|
135 |
$ret=$expression;
|
|
|
136 |
if($required)
|
|
|
137 |
{
|
|
|
138 |
if($ret)
|
|
|
139 |
$ret='passed';
|
|
|
140 |
else
|
|
|
141 |
{
|
|
|
142 |
$conclusion=1;
|
|
|
143 |
$ret='error';
|
|
|
144 |
}
|
|
|
145 |
}
|
|
|
146 |
else
|
|
|
147 |
{
|
|
|
148 |
if($ret)
|
|
|
149 |
$ret='passed';
|
|
|
150 |
else
|
|
|
151 |
{
|
|
|
152 |
if($conclusion!==1)
|
|
|
153 |
$conclusion=2;
|
|
|
154 |
$ret='warning';
|
|
|
155 |
}
|
|
|
156 |
}
|
|
|
157 |
$results.="<tr class=\"$ret\"><td class=\"$ret\">".lmessage($aspect)."</td><td class=\"$ret\">".lmessage($hint)."</td></tr>\n";
|
|
|
158 |
}
|
|
|
159 |
$results .= '</table>';
|
|
|
160 |
if($conclusion===0)
|
|
|
161 |
$conclusion=lmessage('all passed');
|
|
|
162 |
else if($conclusion===1)
|
|
|
163 |
$conclusion=lmessage('failed');
|
|
|
164 |
else
|
|
|
165 |
$conclusion=lmessage('passed with warnings');
|
|
|
166 |
|
|
|
167 |
$tokens = array(
|
|
|
168 |
'%%Conclusion%%' => $conclusion,
|
|
|
169 |
'%%Details%%' => $results,
|
|
|
170 |
'%%Version%%' => $_SERVER['SERVER_SOFTWARE'].' <a href="http://www.pradosoft.com/">PRADO</a>/'.getPradoVersion(),
|
|
|
171 |
'%%Time%%' => @strftime('%Y-%m-%d %H:%m',time()),
|
|
|
172 |
);
|
|
|
173 |
|
|
|
174 |
$lang=getPreferredLanguage();
|
|
|
175 |
$templateFile=dirname(__FILE__)."/template-$lang.html";
|
|
|
176 |
if(!is_file($templateFile))
|
|
|
177 |
$templateFile=dirname(__FILE__).'/template.html';
|
|
|
178 |
if(($content=@file_get_contents($templateFile))===false)
|
|
|
179 |
die("Unable to open template file '$templateFile'.");
|
|
|
180 |
|
|
|
181 |
header('Content-Type: text/html; charset=UTF-8');
|
|
|
182 |
echo strtr($content,$tokens);
|
|
|
183 |
|
|
|
184 |
/**
|
|
|
185 |
* Returns a localized message according to user preferred language.
|
|
|
186 |
* @param string message to be translated
|
|
|
187 |
* @return string translated message
|
|
|
188 |
*/
|
|
|
189 |
function lmessage($token)
|
|
|
190 |
{
|
|
|
191 |
static $messages=null;
|
|
|
192 |
if($messages===null)
|
|
|
193 |
{
|
|
|
194 |
$lang = getPreferredLanguage();
|
|
|
195 |
$msgFile=dirname(__FILE__)."/messages-$lang.txt";
|
|
|
196 |
if(!is_file($msgFile))
|
|
|
197 |
$msgFile=dirname(__FILE__).'/messages.txt';
|
|
|
198 |
if(($entries=@file($msgFile))!==false)
|
|
|
199 |
{
|
|
|
200 |
foreach($entries as $entry)
|
|
|
201 |
{
|
|
|
202 |
@list($code,$message)=explode('=',$entry,2);
|
|
|
203 |
$messages[trim($code)]=trim($message);
|
|
|
204 |
}
|
|
|
205 |
}
|
|
|
206 |
}
|
|
|
207 |
return isset($messages[$token])?$messages[$token]:$token;
|
|
|
208 |
}
|
|
|
209 |
|
|
|
210 |
/**
|
|
|
211 |
* Returns a list of user preferred languages.
|
|
|
212 |
* The languages are returned as an array. Each array element
|
|
|
213 |
* represents a single language preference. The languages are ordered
|
|
|
214 |
* according to user preferences. The first language is the most preferred.
|
|
|
215 |
* @return array list of user preferred languages.
|
|
|
216 |
*/
|
|
|
217 |
function getUserLanguages()
|
|
|
218 |
{
|
|
|
219 |
static $languages=null;
|
|
|
220 |
if($languages===null)
|
|
|
221 |
{
|
|
|
222 |
$languages=array();
|
|
|
223 |
foreach(explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']) as $language)
|
|
|
224 |
{
|
|
|
225 |
$array=split(';q=',trim($language));
|
|
|
226 |
$languages[trim($array[0])]=isset($array[1])?(float)$array[1]:1.0;
|
|
|
227 |
}
|
|
|
228 |
arsort($languages);
|
|
|
229 |
$languages=array_keys($languages);
|
|
|
230 |
if(empty($languages))
|
|
|
231 |
$languages[0]='en';
|
|
|
232 |
}
|
|
|
233 |
return $languages;
|
|
|
234 |
}
|
|
|
235 |
|
|
|
236 |
/**
|
|
|
237 |
* Returns the most preferred language by the client user.
|
|
|
238 |
* @return string the most preferred language by the client user, defaults to English.
|
|
|
239 |
*/
|
|
|
240 |
function getPreferredLanguage()
|
|
|
241 |
{
|
|
|
242 |
static $language=null;
|
|
|
243 |
if($language===null)
|
|
|
244 |
{
|
|
|
245 |
$langs=getUserLanguages();
|
|
|
246 |
$lang=explode('-',$langs[0]);
|
|
|
247 |
if(empty($lang[0]) || !function_exists('ctype_alpha') || !ctype_alpha($lang[0]))
|
|
|
248 |
$language='en';
|
|
|
249 |
else
|
|
|
250 |
$language=$lang[0];
|
|
|
251 |
}
|
|
|
252 |
return $language;
|
|
|
253 |
}
|
|
|
254 |
|
|
|
255 |
/**
|
|
|
256 |
* @return string Prado version
|
|
|
257 |
*/
|
|
|
258 |
function getPradoVersion()
|
|
|
259 |
{
|
|
|
260 |
$coreFile=dirname(__FILE__).'/../framework/PradoBase.php';
|
|
|
261 |
if(is_file($coreFile))
|
|
|
262 |
{
|
|
|
263 |
$contents=file_get_contents($coreFile);
|
|
|
264 |
$matches=array();
|
|
|
265 |
if(preg_match('/public static function getVersion.*?return \'(.*?)\'/ms',$contents,$matches)>0)
|
|
|
266 |
return $matches[1];
|
|
|
267 |
}
|
|
|
268 |
return '';
|
|
|
269 |
}
|
|
|
270 |
|
|
|
271 |
?>
|