<HTML>
<HEAD>
<STYLE>
BODY{
background:ThreeDFace;
font-face:verdana;
font-size:16px;
}
TH {
background:DarkSeaGreen;
}
TD {
padding-left:10px;
padding-right:10px;
background:transparent;
}
</STYLE>
</HEAD>
<BODY>
<?php
/* database connection info */
/* Please make sure the DB type (MYSQL/PGSQL) before continue. */
$host = "localhost";
$user = "root";
$passwd = "passwd";
$db = "moodle";
function check_php_version($version='4.1.0') {
return (version_compare(phpversion(), $version) >= 0);
}
function ini_get_bool($ini_get_arg) {
$temp = ini_get($ini_get_arg);
if ($temp == '1' or strtolower($temp) == 'on') {
return true;
}
return false;
}
function check_gd_version() {
$gdversion = 0;
if (function_exists('gd_info')){
$gd_info = gd_info();
if (substr_count($gd_info['GD Version'], '2.')) {
$gdversion = 2;
} else if (substr_count($gd_info['GD Version'], '1.')) {
$gdversion = 1;
}
} else {
ob_start();
phpinfo(INFO_MODULES);
$phpinfo = ob_get_contents();
ob_end_clean();
$phpinfo = explode("\n", $phpinfo);
foreach ($phpinfo as $text) {
$parts = explode('</td>', $text);
foreach ($parts as $key => $val) {
$parts[$key] = trim(strip_tags($val));
}
if ($parts[0] == 'GD Version') {
if (substr_count($parts[1], '2.0')) {
$parts[1] = '2.0';
}
$gdversion = intval($parts[1]);
}
}
}
return $gdversion; // 1, 2 or 0
}
function get_memory_limit() {
if ($limit = ini_get('memory_limit')) {
return $limit;
} else {
return get_cfg_var('memory_limit');
}
}
//============================//
function check_memory_limit() {
/// if limit is already 40 or more then we don't care if we can change it or not
if ((int)str_replace('M', '', get_memory_limit()) >= 40) {
return true;
}
/// Otherwise, see if we can change it ourselves
raise_memory_limit('40M');
return ((int)str_replace('M', '', get_memory_limit()) >= 40);
}
//============================//
function inst_check_php_version() {
if (!check_php_version("4.3.0")) {
return false;
} else if (check_php_version("5.0.0")) {
return check_php_version("5.1.0"); // 5.0.x is too buggy
}
return true; // 4.3.x or 4.4.x is fine
}
function make_list(){
echo "<table>";
}
function make_list_header($t){
echo "<tr><th>$t[0]</th><th>$t[1]</th><th>$t[2]</th></tr>";
}
function make_listitem($cols){
echo "<tr><td>".$cols[0]."</td><td>".$cols[1]."</td><td>".$cols[2]."</td>";
}
function close_list(){
echo "</table>";
}
function make_list_heading($str){
echo "<h2>$str</h2>";
}
$chklist = array(0=>"inst_check_php_version()");
make_list();
make_list_header(array(0=>"Setting","Condition","Status"));
echo make_list_heading("PHP Settings status");
/// Check that PHP is of a sufficient version
$col1 = "PHP version";
$col2= "> 4.3.0";
if(inst_check_php_version()){
$col3 = "Pass. You are running " . phpversion();
}else{
$col3 = "PHP version must be at least 4.3.0 or 5.1.0 (5.0.x has a number of known problems. you are running ". phpversion();
}
make_listitem(array(0=>$col1,$col2,$col3));
$col1 = "Session Auto Start";
$col2 = "OFF";
/// Check session auto start
if(!ini_get_bool('session.auto_start')){
$col3 = "Pass";
}else{
$col3 = "This should be off. Moodle requires session support and will not function without it.";
}
make_listitem(array(0=>$col1,$col2,$col3));
$col1 = "Magic Quotes Run Time";
$col2 = "OFF";
/// Check magic quotes
if(!ini_get_bool('magic_quotes_runtime')){
$col3 = "Pass";
}else{
$col3 = "This should be off. </li><li>Magic quotes runtime should be turned off for Moodle to function properly.";
}
make_listitem(array(0=>$col1,$col2,$col3));
$col1 = "Insecure Handling of Globals";
$col2 = "OFF";
/// Check unsupported PHP configuration
if(!ini_get_bool('register_globals')){
$col3 = "Pass";
}else{
$col3 = "Fix your PHP settings: disable register_globals and/or enable magic_quotes_gpc. </li><li>Combination of disabled Magic Quotes GPC and enabled Register Globals both at the same time is not recommended.";
}
make_listitem(array(0=>$col1,$col2,$col3));
$col1 = "Safe Mode";
$col2 = "OFF";
/// Check unsupported PHP configuration
if(!ini_get_bool('safe_mode')){
$col3 = "Pass";
}else{
$col3 = "Moodle may have trouble with safe mode on. Moodle may have a variety of problems with safe mode on, not least is that it probably won\'t be allowed to create new files.";
}
make_listitem(array(0=>$col1,$col2,$col3));
$col1 = "File Upload";
$col2 = "OFF";
/// Check unsupported PHP configuration
if(ini_get_bool('file_uploads')){
$col3 = "Pass";
}else{
$col3 = "This should be on. File uploading seems to be disabled on your server.";
}
make_listitem(array(0=>$col1,$col2,$col3));
$col1 = "GD Version";
$col2 = "On";
if(check_gd_version()){
$col3 = "Pass";
}else{
$col3 = "The GD library should be present to process and create images. Your server does not seem to have GD installed.";
}
make_listitem(array(0=>$col1,$col2,$col3));
$col1 = "Memory lImit";
$col2 = ">= 40MB";
if(check_memory_limit()){
$col3 = "Pass : ". ini_get('memory_limit');
}else{
$col3 = "The PHP memory limit is set quite low ... you may run into problems later. The PHP memory limit for your server is currently set to " .ini_get('memory_limit');
}
make_listitem(array(0=>$col1,$col2,$col3));
close_list();
//---------------------extension status --------------------
make_list_heading("PHP Extensions status");
$install_rel = "1.9.8 (Build: 20100325)";
$exts = array(0=>"mysql", "iconv", "mbstring", "curl", "openssl", "tokenizer", "xmlrpc", "ctype");
make_list();
make_list_header(array(0=>"Extension","Should be","Status"));
foreach($exts as $ext){
$col1 = $ext;
$col2 = "Enabled";
if (extension_loaded($ext)) {
$col3 = "Pass";
}else{
$col3 = "Should be installed and enabled for best results";
}
make_listitem(array(0=>$col1,$col2,$col3));
}
//---------------------Unicode and all --------------------
$unicodedb = "";
$conn = mysql_connect($host, $user, $passwd);
if($conn){
mysql_select_db($db);
$rs = mysql_query("SHOW LOCAL VARIABLES LIKE 'character_set_database'", $conn);
if ($rs && !$rs->EOF) { // rs_EOF() not available yet
$records = mysql_fetch_assoc($rs);
$encoding = $records['Value'];
if (strtoupper($encoding) == 'UTF8') {
$unicodedb = true;
}else{
$unicodedb = false;
}
}else{
//$unicodedb = false; do nothing
}
close_list();
make_list_heading("Others");
make_list();
make_list_header(array(0=>"Item","Condition","Status"));
$col1 = "Unicode DB support";
$col2 = "supports utf8";
if($unicodedb){
$col3 = "Pass";
}elseif (!$unicodedb and $unicodedb != ""){
$col3 = "Unicode Support not found.";
}else{
$col3 = "DB not found.";
}
make_listitem(array(0=>$col1,$col2,$col3));
}
$col1 = "MySQL Client Library";
$col2 = "> 4.1.16";
if (version_compare(mysql_get_client_info(), "4.1.16", '>=')) {
$col3 = "Pass. <br/>Current installed Client version : ". mysql_get_client_info();
$col3 .= "<br/>Currently installed server version". mysql_get_server_info();
}else{
$col3 = "Version 4.1.16 is required and you are running ".mysql_get_client_info();
}
make_listitem(array(0=>$col1,$col2,$col3));
$col1 = "PHP version";
$col2 = "> 4.3.0";
if (version_compare(phpversion(), "4.3.0", '>=')) {
$col3 = "Pass<br/>Current installed version : ". phpversion();
}else{
$col3 = "Version 4.3.0 is required and you are running ".phpversion();
}
make_listitem(array(0=>$col1,$col2,$col3));
close_list();
make_list_heading("Apache modules enabled");
make_list();
make_list_header(array(0=>"Extention","Status","-"));
foreach(apache_get_modules() as $mod){
$col1 = "$mod";
$col2 = "Enabled";
$col3 = " ";
make_listitem(array(0=>$col1,$col2,$col3));
}
close_list();
?>
</BODY>
<HTML>
Output:
<HEAD>
<STYLE>
BODY{
background:ThreeDFace;
font-face:verdana;
font-size:16px;
}
TH {
background:DarkSeaGreen;
}
TD {
padding-left:10px;
padding-right:10px;
background:transparent;
}
</STYLE>
</HEAD>
<BODY>
<?php
/* database connection info */
/* Please make sure the DB type (MYSQL/PGSQL) before continue. */
$host = "localhost";
$user = "root";
$passwd = "passwd";
$db = "moodle";
function check_php_version($version='4.1.0') {
return (version_compare(phpversion(), $version) >= 0);
}
function ini_get_bool($ini_get_arg) {
$temp = ini_get($ini_get_arg);
if ($temp == '1' or strtolower($temp) == 'on') {
return true;
}
return false;
}
function check_gd_version() {
$gdversion = 0;
if (function_exists('gd_info')){
$gd_info = gd_info();
if (substr_count($gd_info['GD Version'], '2.')) {
$gdversion = 2;
} else if (substr_count($gd_info['GD Version'], '1.')) {
$gdversion = 1;
}
} else {
ob_start();
phpinfo(INFO_MODULES);
$phpinfo = ob_get_contents();
ob_end_clean();
$phpinfo = explode("\n", $phpinfo);
foreach ($phpinfo as $text) {
$parts = explode('</td>', $text);
foreach ($parts as $key => $val) {
$parts[$key] = trim(strip_tags($val));
}
if ($parts[0] == 'GD Version') {
if (substr_count($parts[1], '2.0')) {
$parts[1] = '2.0';
}
$gdversion = intval($parts[1]);
}
}
}
return $gdversion; // 1, 2 or 0
}
function get_memory_limit() {
if ($limit = ini_get('memory_limit')) {
return $limit;
} else {
return get_cfg_var('memory_limit');
}
}
//============================//
function check_memory_limit() {
/// if limit is already 40 or more then we don't care if we can change it or not
if ((int)str_replace('M', '', get_memory_limit()) >= 40) {
return true;
}
/// Otherwise, see if we can change it ourselves
raise_memory_limit('40M');
return ((int)str_replace('M', '', get_memory_limit()) >= 40);
}
//============================//
function inst_check_php_version() {
if (!check_php_version("4.3.0")) {
return false;
} else if (check_php_version("5.0.0")) {
return check_php_version("5.1.0"); // 5.0.x is too buggy
}
return true; // 4.3.x or 4.4.x is fine
}
function make_list(){
echo "<table>";
}
function make_list_header($t){
echo "<tr><th>$t[0]</th><th>$t[1]</th><th>$t[2]</th></tr>";
}
function make_listitem($cols){
echo "<tr><td>".$cols[0]."</td><td>".$cols[1]."</td><td>".$cols[2]."</td>";
}
function close_list(){
echo "</table>";
}
function make_list_heading($str){
echo "<h2>$str</h2>";
}
$chklist = array(0=>"inst_check_php_version()");
make_list();
make_list_header(array(0=>"Setting","Condition","Status"));
echo make_list_heading("PHP Settings status");
/// Check that PHP is of a sufficient version
$col1 = "PHP version";
$col2= "> 4.3.0";
if(inst_check_php_version()){
$col3 = "Pass. You are running " . phpversion();
}else{
$col3 = "PHP version must be at least 4.3.0 or 5.1.0 (5.0.x has a number of known problems. you are running ". phpversion();
}
make_listitem(array(0=>$col1,$col2,$col3));
$col1 = "Session Auto Start";
$col2 = "OFF";
/// Check session auto start
if(!ini_get_bool('session.auto_start')){
$col3 = "Pass";
}else{
$col3 = "This should be off. Moodle requires session support and will not function without it.";
}
make_listitem(array(0=>$col1,$col2,$col3));
$col1 = "Magic Quotes Run Time";
$col2 = "OFF";
/// Check magic quotes
if(!ini_get_bool('magic_quotes_runtime')){
$col3 = "Pass";
}else{
$col3 = "This should be off. </li><li>Magic quotes runtime should be turned off for Moodle to function properly.";
}
make_listitem(array(0=>$col1,$col2,$col3));
$col1 = "Insecure Handling of Globals";
$col2 = "OFF";
/// Check unsupported PHP configuration
if(!ini_get_bool('register_globals')){
$col3 = "Pass";
}else{
$col3 = "Fix your PHP settings: disable register_globals and/or enable magic_quotes_gpc. </li><li>Combination of disabled Magic Quotes GPC and enabled Register Globals both at the same time is not recommended.";
}
make_listitem(array(0=>$col1,$col2,$col3));
$col1 = "Safe Mode";
$col2 = "OFF";
/// Check unsupported PHP configuration
if(!ini_get_bool('safe_mode')){
$col3 = "Pass";
}else{
$col3 = "Moodle may have trouble with safe mode on. Moodle may have a variety of problems with safe mode on, not least is that it probably won\'t be allowed to create new files.";
}
make_listitem(array(0=>$col1,$col2,$col3));
$col1 = "File Upload";
$col2 = "OFF";
/// Check unsupported PHP configuration
if(ini_get_bool('file_uploads')){
$col3 = "Pass";
}else{
$col3 = "This should be on. File uploading seems to be disabled on your server.";
}
make_listitem(array(0=>$col1,$col2,$col3));
$col1 = "GD Version";
$col2 = "On";
if(check_gd_version()){
$col3 = "Pass";
}else{
$col3 = "The GD library should be present to process and create images. Your server does not seem to have GD installed.";
}
make_listitem(array(0=>$col1,$col2,$col3));
$col1 = "Memory lImit";
$col2 = ">= 40MB";
if(check_memory_limit()){
$col3 = "Pass : ". ini_get('memory_limit');
}else{
$col3 = "The PHP memory limit is set quite low ... you may run into problems later. The PHP memory limit for your server is currently set to " .ini_get('memory_limit');
}
make_listitem(array(0=>$col1,$col2,$col3));
close_list();
//---------------------extension status --------------------
make_list_heading("PHP Extensions status");
$install_rel = "1.9.8 (Build: 20100325)";
$exts = array(0=>"mysql", "iconv", "mbstring", "curl", "openssl", "tokenizer", "xmlrpc", "ctype");
make_list();
make_list_header(array(0=>"Extension","Should be","Status"));
foreach($exts as $ext){
$col1 = $ext;
$col2 = "Enabled";
if (extension_loaded($ext)) {
$col3 = "Pass";
}else{
$col3 = "Should be installed and enabled for best results";
}
make_listitem(array(0=>$col1,$col2,$col3));
}
//---------------------Unicode and all --------------------
$unicodedb = "";
$conn = mysql_connect($host, $user, $passwd);
if($conn){
mysql_select_db($db);
$rs = mysql_query("SHOW LOCAL VARIABLES LIKE 'character_set_database'", $conn);
if ($rs && !$rs->EOF) { // rs_EOF() not available yet
$records = mysql_fetch_assoc($rs);
$encoding = $records['Value'];
if (strtoupper($encoding) == 'UTF8') {
$unicodedb = true;
}else{
$unicodedb = false;
}
}else{
//$unicodedb = false; do nothing
}
close_list();
make_list_heading("Others");
make_list();
make_list_header(array(0=>"Item","Condition","Status"));
$col1 = "Unicode DB support";
$col2 = "supports utf8";
if($unicodedb){
$col3 = "Pass";
}elseif (!$unicodedb and $unicodedb != ""){
$col3 = "Unicode Support not found.";
}else{
$col3 = "DB not found.";
}
make_listitem(array(0=>$col1,$col2,$col3));
}
$col1 = "MySQL Client Library";
$col2 = "> 4.1.16";
if (version_compare(mysql_get_client_info(), "4.1.16", '>=')) {
$col3 = "Pass. <br/>Current installed Client version : ". mysql_get_client_info();
$col3 .= "<br/>Currently installed server version". mysql_get_server_info();
}else{
$col3 = "Version 4.1.16 is required and you are running ".mysql_get_client_info();
}
make_listitem(array(0=>$col1,$col2,$col3));
$col1 = "PHP version";
$col2 = "> 4.3.0";
if (version_compare(phpversion(), "4.3.0", '>=')) {
$col3 = "Pass<br/>Current installed version : ". phpversion();
}else{
$col3 = "Version 4.3.0 is required and you are running ".phpversion();
}
make_listitem(array(0=>$col1,$col2,$col3));
close_list();
make_list_heading("Apache modules enabled");
make_list();
make_list_header(array(0=>"Extention","Status","-"));
foreach(apache_get_modules() as $mod){
$col1 = "$mod";
$col2 = "Enabled";
$col3 = " ";
make_listitem(array(0=>$col1,$col2,$col3));
}
close_list();
?>
</BODY>
<HTML>
Output:
PHP Settings status
Setting | Condition | Status |
---|---|---|
PHP version | > 4.3.0 | Pass. You are running 5.3.5-1ubuntu7.2 |
Session Auto Start | OFF | Pass |
Magic Quotes Run Time | OFF | Pass |
Insecure Handling of Globals | OFF | Pass |
Safe Mode | OFF | Pass |
File Upload | OFF | Pass |
GD Version | On | Pass |
Memory lImit | >= 40MB | Pass : 128M |
PHP Extensions status
Extension | Should be | Status |
---|---|---|
mysql | Enabled | Pass |
iconv | Enabled | Pass |
mbstring | Enabled | Pass |
curl | Enabled | Should be installed and enabled for best results |
openssl | Enabled | Pass |
tokenizer | Enabled | Pass |
xmlrpc | Enabled | Pass |
ctype | Enabled | Pass |
Others
Item | Condition | Status |
---|---|---|
Unicode DB support | supports utf8 | DB not found. |
MySQL Client Library | > 4.1.16 | Pass. Current installed Client version : 5.1.54 Currently installed server version5.1.54-1ubuntu4 |
PHP version | > 4.3.0 | Pass Current installed version : 5.3.5-1ubuntu7.2 |
Apache modules enabled
Extention | Status | - |
---|---|---|
core | Enabled | |
mod_log_config | Enabled | |
mod_logio | Enabled | |
prefork | Enabled | |
http_core | Enabled | |
mod_so | Enabled | |
mod_alias | Enabled | |
mod_auth_basic | Enabled | |
mod_authn_file | Enabled | |
mod_authz_default | Enabled | |
mod_authz_groupfile | Enabled | |
mod_authz_host | Enabled | |
mod_authz_user | Enabled | |
mod_autoindex | Enabled | |
mod_cgi | Enabled | |
mod_deflate | Enabled | |
mod_dir | Enabled | |
mod_env | Enabled | |
mod_mime | Enabled | |
mod_negotiation | Enabled | |
mod_php5 | Enabled | |
mod_reqtimeout | Enabled | |
mod_rewrite | Enabled | |
mod_setenvif | Enabled | |
mod_status | Enabled |
No comments:
Post a Comment