summaryrefslogtreecommitdiff
path: root/lib/prado/requirements
diff options
context:
space:
mode:
Diffstat (limited to 'lib/prado/requirements')
-rw-r--r--lib/prado/requirements/index.php292
-rw-r--r--lib/prado/requirements/messages.txt49
-rw-r--r--lib/prado/requirements/template.html49
3 files changed, 390 insertions, 0 deletions
diff --git a/lib/prado/requirements/index.php b/lib/prado/requirements/index.php
new file mode 100644
index 0000000..85bb160
--- /dev/null
+++ b/lib/prado/requirements/index.php
@@ -0,0 +1,292 @@
+<?php
+/**
+ * PRADO Requirements Checker script
+ *
+ * @author Qiang Xue <qiang.xue@gmail.com>
+ * @link https://github.com/pradosoft/prado
+ * @copyright Copyright &copy; 2005-2015 The PRADO Group
+ * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
+ * @package prado
+ */
+
+/**
+ * PRADO Requirements Checker script
+ *
+ * This script will check if your system meets the requirements for running PRADO.
+ * It will check if you are running the right version of PHP, if you included
+ * the right libraries and if your php.ini file settings are correct.
+ *
+ * This script is capable of displaying localized messages.
+ * All messages are stored in messages.txt. A localized message file is named as
+ * messsages-<language code>.txt, and it will be used when the client browser
+ * chooses the corresponding language.
+ * The script output uses a template named template.html.
+ * Its localized version is stored in template-<language code>.html.
+ */
+
+/**
+ * @var array List of requirements (required or not, check item, hint)
+ */
+$requirements = array(
+ array(
+ true,
+ version_compare(PHP_VERSION,"5.3.3",">="),
+ 'PHP version check','PHP 5.3.3 or higher required'),
+ array(
+ true,
+ isset($_SERVER["HTTP_ACCEPT"]),
+ '$_SERVER["HTTP_ACCEPT"] check',
+ 'HTTP_ACCEPT required'),
+ array(
+ true,
+ isset($_SERVER["SCRIPT_FILENAME"]) && realpath($_SERVER["SCRIPT_FILENAME"])===realpath(__FILE__),
+ '$_SERVER["SCRIPT_FILENAME"] check',
+ 'SCRIPT_FILENAME required'),
+ array(
+ true,
+ isset($_SERVER["REQUEST_URI"]) || isset($_SERVER["QUERY_STRING"]),
+ '$_SERVER["REQUEST_URI"] check',
+ 'REQUEST_URI required'),
+ array(
+ true,
+ isset($_SERVER["PATH_INFO"]) || strpos($_SERVER["PHP_SELF"],$_SERVER["SCRIPT_NAME"])===0,
+ '$_SERVER["PATH_INFO"] check',
+ 'PATH_INFO required'),
+ array(
+ true,
+ class_exists('Reflection',false),
+ 'Reflection extension check',
+ 'Reflection extension required'),
+ array(
+ true,
+ class_exists("DOMDocument",false),
+ 'DOM extension check',
+ 'DOM extension required'),
+ array(
+ true,
+ extension_loaded("SPL"),
+ 'SPL extension check',
+ 'SPL extension required'),
+ array(
+ true,
+ extension_loaded("CType"),
+ 'CType extension check',
+ 'CType extension required'),
+ array(
+ true,
+ extension_loaded("pcre"),
+ 'PCRE extension check',
+ 'PCRE extension required'),
+ array(
+ true,
+ extension_loaded("json"),
+ 'JSON extension check',
+ 'JSON extension required'),
+ array(
+ false,
+ class_exists("PDO",false),
+ 'PDO extension check',
+ 'PDO extension optional'),
+ array(
+ false,
+ function_exists("iconv"),
+ 'ICONV extension check',
+ 'ICONV extension optional'),
+ array(
+ false,
+ extension_loaded("zlib"),
+ 'Zlib extension check',
+ 'Zlib extension optional'),
+ array(
+ false,
+ extension_loaded("sqlite"),
+ 'SQLite extension check',
+ 'SQLite extension optional deprecated'),
+ array(
+ false,
+ extension_loaded("memcache"),
+ 'Memcache extension check',
+ 'Memcache extension optional'),
+ array(
+ false,
+ extension_loaded("apc"),
+ 'APC extension check',
+ 'APC extension optional'),
+ array(
+ false,
+ function_exists('eaccelerator_get'),
+ 'eAccelerator extension check',
+ 'eAccelerator extension optional'),
+ array(
+ false,
+ function_exists('xcache_isset'),
+ 'XCache extension check',
+ 'XCache extension optional'),
+ array(
+ false,
+ extension_loaded("mcrypt"),
+ 'Mcrypt extension check',
+ 'Mcrypt extension optional'),
+ array(
+ false,
+ extension_loaded("mbstring"),
+ 'Mbstring extension check',
+ 'Mbstring extension optional'),
+ array(
+ false,
+ extension_loaded("hash"),
+ 'Hash extension check',
+ 'Hash extension optional'),
+ array(
+ false,
+ extension_loaded("xsl"),
+ 'XSL extension check',
+ 'XSL extension optional'),
+ array(
+ false,
+ extension_loaded("soap"),
+ 'SOAP extension check',
+ 'SOAP extension optional'),
+);
+
+$results = "<table class=\"result\">\n";
+$conclusion = 0;
+foreach($requirements as $requirement)
+{
+ list($required,$expression,$aspect,$hint)=$requirement;
+ //eval('$ret='.$expression.';');
+ $ret=$expression;
+ if($required)
+ {
+ if($ret)
+ $ret='passed';
+ else
+ {
+ $conclusion=1;
+ $ret='error';
+ }
+ }
+ else
+ {
+ if($ret)
+ $ret='passed';
+ else
+ {
+ if($conclusion!==1)
+ $conclusion=2;
+ $ret='warning';
+ }
+ }
+ $results.="<tr class=\"$ret\"><td class=\"$ret\">".lmessage($aspect)."</td><td class=\"$ret\">".lmessage($hint)."</td></tr>\n";
+}
+$results .= '</table>';
+if($conclusion===0)
+ $conclusion=lmessage('all passed');
+else if($conclusion===1)
+ $conclusion=lmessage('failed');
+else
+ $conclusion=lmessage('passed with warnings');
+
+$tokens = array(
+ '%%Conclusion%%' => $conclusion,
+ '%%Details%%' => $results,
+ '%%Version%%' => $_SERVER['SERVER_SOFTWARE'].' <a href="https://github.com/pradosoft/prado">PRADO</a>/'.getPradoVersion(),
+ '%%Time%%' => @strftime('%Y-%m-%d %H:%m',time()),
+);
+
+$lang=getPreferredLanguage();
+$templateFile=dirname(__FILE__)."/template-$lang.html";
+if(!is_file($templateFile))
+ $templateFile=dirname(__FILE__).'/template.html';
+if(($content=@file_get_contents($templateFile))===false)
+ die("Unable to open template file '$templateFile'.");
+
+header('Content-Type: text/html; charset=UTF-8');
+echo strtr($content,$tokens);
+
+/**
+ * Returns a localized message according to user preferred language.
+ * @param string message to be translated
+ * @return string translated message
+ */
+function lmessage($token)
+{
+ static $messages=null;
+ if($messages===null)
+ {
+ $lang = getPreferredLanguage();
+ $msgFile=dirname(__FILE__)."/messages-$lang.txt";
+ if(!is_file($msgFile))
+ $msgFile=dirname(__FILE__).'/messages.txt';
+ if(($entries=@file($msgFile))!==false)
+ {
+ foreach($entries as $entry)
+ {
+ @list($code,$message)=explode('=',$entry,2);
+ $messages[trim($code)]=trim($message);
+ }
+ }
+ }
+ return isset($messages[$token])?$messages[$token]:$token;
+}
+
+/**
+ * Returns a list of user preferred languages.
+ * The languages are returned as an array. Each array element
+ * represents a single language preference. The languages are ordered
+ * according to user preferences. The first language is the most preferred.
+ * @return array list of user preferred languages.
+ */
+function getUserLanguages()
+{
+ static $languages=null;
+ if($languages===null)
+ {
+ $languages=array();
+ foreach(explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']) as $language)
+ {
+ $array=explode(';q=',trim($language));
+ $languages[trim($array[0])]=isset($array[1])?(float)$array[1]:1.0;
+ }
+ arsort($languages);
+ $languages=array_keys($languages);
+ if(empty($languages))
+ $languages[0]='en';
+ }
+ return $languages;
+}
+
+/**
+ * Returns the most preferred language by the client user.
+ * @return string the most preferred language by the client user, defaults to English.
+ */
+function getPreferredLanguage()
+{
+ static $language=null;
+ if($language===null)
+ {
+ $langs=getUserLanguages();
+ $lang=explode('-',$langs[0]);
+ if(empty($lang[0]) || !function_exists('ctype_alpha') || !ctype_alpha($lang[0]))
+ $language='en';
+ else
+ $language=$lang[0];
+ }
+ return $language;
+}
+
+/**
+ * @return string Prado version
+ */
+function getPradoVersion()
+{
+ $coreFile=dirname(__FILE__).'/../framework/PradoBase.php';
+ if(is_file($coreFile))
+ {
+ $contents=file_get_contents($coreFile);
+ $matches=array();
+ if(preg_match('/public static function getVersion.*?return \'(.*?)\'/ms',$contents,$matches)>0)
+ return $matches[1];
+ }
+ return '';
+}
diff --git a/lib/prado/requirements/messages.txt b/lib/prado/requirements/messages.txt
new file mode 100644
index 0000000..5145fd7
--- /dev/null
+++ b/lib/prado/requirements/messages.txt
@@ -0,0 +1,49 @@
+all passed = Congratulations! Your server configuration satisfies all requirements by PRADO.
+passed with warnings = Your server configuration satisfies minimum requirements by PRADO. Please pay attention to the warnings listed below.
+failed = Sorry, your server configuration does not satisfy the requirements by PRADO.
+PHP version check = PHP version check
+PHP 5.3.3 or higher required = PHP version 5.3.3 or higher is required by PRADO.
+SQLite extension check = SQLite extension check
+SQLite extension optional deprecated = SQLite extension is deprecated, but can still be used optionally to support old code.
+Memcache extension check = Memcache extension check
+Memcache extension optional = Memcache extension is optional. If it is absent, you will not be able to use TMemCache.
+APC extension check = APC extension check
+APC extension optional = APC extension is optional. If it is absent, you will not be able to use TAPCCache.
+eAccelerator extension check = eAccelerator extension check
+eAccelerator extension optional = eAccelerator extension is optional. If it is absent, you will not be able to use TEACache.
+XCache extension check = XCache extension check
+XCache extension optional = XCache extension is optional. If it is absent, you will not be able to use TXCache.
+Zlib extension check = Zlib extension check
+Zlib extension optional = Zlib extension is optional. If it is absent, page state will not be compressed and your page size may increase.
+Reflection extension check = Reflection extension check
+Reflection extension required = Reflection extension is required by PRADO. It is used in by PRADO to check the validity of page templates.
+DOM extension check = DOM extension check
+DOM extension required = DOM extension is required by PRADO. It is used in TXmlDocument to parse all sorts of XML-based configurations.
+ICONV extension check = ICONV extension check
+ICONV extension optional = ICONV extension is optional. If it is absent, some internationalization components may not work properly.
+Mcrypt extension check = Mcrypt extension check
+Mcrypt extension optional = Mcrypt extension is optional. If it is absent, sensitive data, such as viewstate, cannot be encrypted.
+Mbstring extension check = Mbstring extension check
+Mbstring extension optional = Mbstring extension is optional. If it is absent, prado will fallback using the not unicode-aware functions.
+Hash extension check = Hash extension check
+Hash extension optional = Hash extension is optional. If it is absent, only md5 and sha1 will be supported.
+XSL extension check = XSL extension check
+XSL extension optional = XSL extension is optional. If it is absent, you will not be able to use TXmlTransform.
+$_SERVER["HTTP_ACCEPT"] check = $_SERVER["HTTP_ACCEPT"] check
+HTTP_ACCEPT required = $_SERVER["HTTP_ACCEPT"] is required by multilanguage support.
+$_SERVER["SCRIPT_FILENAME"] check = $_SERVER["SCRIPT_FILENAME"] check
+SCRIPT_FILENAME required = $_SERVER["SCRIPT_FILENAME"] must point to the file path of this checker script.
+$_SERVER["REQUEST_URI"] check = $_SERVER["REQUEST_URI"] check
+REQUEST_URI required = Either $_SERVER["REQUEST_URI"] or $_SERVER["QUERY_STRING"] must be available for resolving user requests.
+$_SERVER["PATH_INFO"] check = $_SERVER["PATH_INFO"] check
+PATH_INFO required = $_SERVER["PATH_INFO"] or $_SERVER["PHP_SELF"] and $_SERVER["SCRIPT_NAME"] are required for determining URL pathinfo.
+SPL extension check = SPL extension check
+SPL extension required = SPL extension is required by PRADO.
+CType extension check = CType extension check
+CType extension required = CType extension is required by PRADO.
+PCRE extension check = PCRE extension check
+PCRE extension required = PCRE extension is required by PRADO.
+PDO extension check = PDO extension check
+PDO extension optional = PDO extension is optional. If it is absent, you will not be able to use System.Data.* components.
+SOAP extension check = SOAP extension check
+SOAP extension optional = SOAP extension is optional. If it is absent, you will not be able to use TSoapService. \ No newline at end of file
diff --git a/lib/prado/requirements/template.html b/lib/prado/requirements/template.html
new file mode 100644
index 0000000..a7cb9c0
--- /dev/null
+++ b/lib/prado/requirements/template.html
@@ -0,0 +1,49 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
+<meta http-equiv="content-language" content="en"/>
+<title>PRADO Requirements Checker</title>
+<style>
+body {font-family:"Verdana";font-weight:normal;color:black;}
+h1 { font-family:"Verdana";font-weight:normal;font-size:18pt; }
+h3 {font-family:"Verdana";font-weight:bold;font-size:11pt}
+p, td {font-family:"Verdana";font-weight:normal;font-size:10pt;}
+table.result {border-collapse: collapse; width: 100%; font-size: 10pt; font-family:"Verdana";}
+td.passed {background-color: #60BF60;border: 1px solid silver; padding: 2px;}
+td.warning {background-color: #FFFFBF;border: 1px solid silver; padding: 2px;}
+td.error {background-color: #FF8080;border: 1px solid silver; padding: 2px;}
+.version {color: gray;font-size:8pt;border-top:1px solid #aaaaaa;}
+</style>
+</head>
+
+<body bgcolor="white">
+<h1>PRADO Requirements Checker</h1>
+<h3>Description</h3>
+<p>
+This script checks if your server configuration meets the requirements
+for running <a href="https://github.com/pradosoft/prado">PRADO</a>-powered applications.
+It checks if the server is running the right version of PHP,
+if appropriate PHP extensions have been loaded, and if php.ini file settings are correct.
+</p>
+<h3>Conclusion</h3>
+<p>
+%%Conclusion%%
+</p>
+<h3>Details</h3>
+</p>
+%%Details%%
+</p>
+<p>
+<table>
+<tr>
+<td class="passed">&nbsp;</td><td>passed</td>
+<td class="error">&nbsp;</td><td>failed</td>
+<td class="warning">&nbsp;</td><td>warning</td>
+</tr>
+</table>
+</p>
+<div class="version">
+%%Time%% %%Version%%
+</div>
+</body>
+</html> \ No newline at end of file