Changing REQUIRED_PHP_VERSION to version 5.3 see #4790

skala
Julio Montoya 13 years ago
parent af695ddde6
commit b358024b89
  1. 28
      main/inc/global.inc.php
  2. 43
      main/inc/global_error_message.inc.php
  3. 4
      main/inc/lib/diagnoser.lib.php
  4. 19
      main/inc/lib/main_api.lib.php
  5. 13
      main/install/index.php
  6. 4
      main/install/install.lib.php

@ -24,21 +24,10 @@
// Showing/hiding error codes in global error messages.
define('SHOW_ERROR_CODES', false);
// PHP version requirement.
define('REQUIRED_PHP_VERSION', '5');
// Determine the directory path where this current file lies.
// This path will be useful to include the other intialisation files.
$includePath = dirname(__FILE__);
// PHP version check.
if (!function_exists('version_compare') || version_compare(phpversion(), REQUIRED_PHP_VERSION, '<')) {
$global_error_code = 1;
// Incorrect PHP version.
require $includePath.'/global_error_message.inc.php';
die();
}
// @todo Isn't this file renamed to configuration.inc.php yet?
// Include the main Chamilo platform configuration file.
$main_configuration_file_path = $includePath.'/conf/configuration.php';
@ -76,9 +65,12 @@ if (empty($_configuration['system_version'])) {
$_configuration['dokeos_version'] = $_configuration['system_version'];
$_configuration['dokeos_stable'] = $_configuration['system_stable'];
// Include the main Chamilo platform library file.
require_once $includePath.'/lib/main_api.lib.php';
check_php_version($includePath.'/');
// Do not over-use this variable. It is only for this script's local use.
$lib_path = api_get_path(LIBRARY_PATH);
@ -95,8 +87,8 @@ ini_set('auto_detect_line_endings', '1');
require_once dirname(__FILE__).'/autoload.inc.php';
require_once $lib_path.'database.lib.php';
require_once $lib_path.'template.lib.php';
require_once $lib_path.'display.lib.php';
//require_once $lib_path.'template.lib.php'; moved to autoload
//require_once $lib_path.'display.lib.php';
require_once $lib_path.'text.lib.php';
//require_once $lib_path.'image.lib.php'; moved to autoload
require_once $lib_path.'array.lib.php';
@ -107,13 +99,13 @@ require_once $lib_path.'events.lib.inc.php';
require_once $lib_path.'model.lib.php';
//require_once $lib_path.'sortable_table.class.php'; moved to autoload
require_once $lib_path.'usermanager.lib.php';
require_once $lib_path.'message.lib.php';
require_once $lib_path.'social.lib.php';
require_once $lib_path.'notification.lib.php';
//require_once $lib_path.'usermanager.lib.php'; moved to autoload
//require_once $lib_path.'message.lib.php'; moved to autoload
//require_once $lib_path.'social.lib.php'; moved to autoload
//require_once $lib_path.'notification.lib.php'; moved to autoload
require_once $lib_path.'course.lib.php';
//require_once $lib_path.'sessionmanager.lib.php'; moved to autoload
require_once $lib_path.'tracking.lib.php';
//require_once $lib_path.'tracking.lib.php'; moved to autoload
//require_once $lib_path.'formvalidator/FormValidator.class.php'; moved to autoload
require_once $lib_path.'online.inc.php';

@ -27,7 +27,8 @@ $ErrorCode = 'Error code';
// Error code 1.
$IncorrectPhpVersionTitle = 'Incorrect PHP version';
$IncorrectPhpVersionDescription = 'Scripting language version %s1 on your server is incorrect. PHP %s2 should be supported. %s3 Read the installation guide.';
$IncorrectPhpVersionDescription = 'Warning: we have detected that your version of PHP is %s1. To install Chamilo, you need to have PHP %s2 or superior. If you don\'t know what we\'re talking about, please contact your hosting provider or your support team.
%s3 Read the installation guide.';
// Error code 2.
$InstallationTitle = 'Chamilo has not been installed';
@ -86,12 +87,10 @@ if (is_int($global_error_code) && $global_error_code > 0) {
$css_base_chamilo_file = $root_sys.$css_item;
if (file_exists($css_base_chamilo_file)) {
$css_def .= @file_get_contents($css_base_chamilo_file);
}
}
}
}
$css_def = str_replace("@import url('bootstrap.css');", '', $css_def);
$css_def = str_replace('behavior:url("/main/css/csshover3.htc");', '', $css_def);
$css_def = str_replace("@import url('bootstrap.css');", '', $css_def);
$css_def = str_replace('main/', $root_rel.'main/', $css_def);
$css_def = str_replace('images/', $root_rel.$css_path.$theme.'images/', $css_def);
$css_def = str_replace('../../img/', $root_rel.'main/img/', $css_def);
@ -111,7 +110,7 @@ if (is_int($global_error_code) && $global_error_code > 0) {
$length = strlen($IncorrectPhpVersionDescription);
$read_installation_guide = substr($IncorrectPhpVersionDescription, $pos + 3, $length);
$IncorrectPhpVersionDescription = substr($IncorrectPhpVersionDescription, 0, $pos);
$IncorrectPhpVersionDescription .= '<br /><a href="'.$installation_guide_url.'" target="_blank">'.$read_installation_guide.'</a>';
$IncorrectPhpVersionDescription .= '<br /><a class="btn" href="'.$installation_guide_url.'" target="_blank">'.$read_installation_guide.'</a>';
}
$global_error_message['description'] = $IncorrectPhpVersionDescription;
break;
@ -179,22 +178,24 @@ if (is_int($global_error_code) && $global_error_code > 0) {
</head>
<body>
<div id="wrapper">
<div id="header">
<div id="logo">
<img vspace="10" hspace="10" alt="Chamilo" src="{CHAMILO_LOGO}">
</div>
<div id="main" class="container">
<header>
<div class="row">
<div id="header_left" class="span4">
<div id="logo">
<img vspace="10" hspace="10" alt="Chamilo" src="{CHAMILO_LOGO}">
</div>
</div>
</header>
<ul class="breadcrumb">
<li><a href="#">{SECTION}</a></li>
</ul>
</div>
<div class="clear"> </div>
<div id="main">
<div style="text-align: center;">
{DESCRIPTION}
{CODE}
</div>
</ul>
<section>
<div style="text-align:center">
{DESCRIPTION}
{CODE}
</div>
</section>
</div>
<div class="push"/></div>
</div>

@ -98,8 +98,8 @@ class Diagnoser
// General Functions
$version = phpversion();
$status = $version > MIN_PHP_VERSION ? self :: STATUS_OK : self :: STATUS_ERROR;
$array[] = $this->build_setting($status, '[PHP]', 'phpversion()', 'http://www.php.net/manual/en/function.phpversion.php', phpversion(), '>= '.MIN_PHP_VERSION, null, get_lang('PHPVersionInfo'));
$status = $version > REQUIRED_PHP_VERSION ? self :: STATUS_OK : self :: STATUS_ERROR;
$array[] = $this->build_setting($status, '[PHP]', 'phpversion()', 'http://www.php.net/manual/en/function.phpversion.php', phpversion(), '>= '.REQUIRED_PHP_VERSION, null, get_lang('PHPVersionInfo'));
$setting = ini_get('output_buffering');
$req_setting = 1;

@ -13,6 +13,9 @@
* Constants declaration
*/
// PHP version requirement.
define('REQUIRED_PHP_VERSION', '5.3');
// USER STATUS CONSTANTS
/** global status of a user: student */
define('STUDENT', 5);
@ -28,7 +31,7 @@ define('ANONYMOUS', 6);
* the teacher through HTMLPurifier */
define('COURSEMANAGERLOWSECURITY', 10);
define('MIN_PHP_VERSION', '5.2.4');
// Table of status
$_status_list[COURSEMANAGER] = 'teacher'; // 1
@ -179,8 +182,6 @@ define('IS_PHP_SUP_OR_EQ_53', ($php_version >= 5.3));
define('IS_PHP_SUP_OR_EQ_52', ($php_version >= 5.2 && !IS_PHP_53));
define('IS_PHP_SUP_OR_EQ_51', ($php_version >= 5.1 && !IS_PHP_52 && !IS_PHP_53));
// This constant is a result of Windows OS detection, it has a boolean value:
// true whether the server runs on Windows OS, false otherwise.
define('IS_WINDOWS_OS', api_is_windows_os());
@ -5802,4 +5803,16 @@ function block_course_item_locked_by_gradebook($item_id, $link_type, $course_cod
$message = Display::return_message(get_lang('ResourceLockedByGradebook'), 'warning');
api_not_allowed(true, $message);
}
}
function check_php_version($my_inc_path = null) {
if (!function_exists('version_compare') || version_compare( phpversion(), REQUIRED_PHP_VERSION, '<')) {
$global_error_code = 1;
// Incorrect PHP version
$global_page = $my_inc_path.'global_error_message.inc.php';
if (file_exists($global_page)) {
require $global_page;
}
exit;
}
}

@ -25,23 +25,16 @@ define('MAX_FORM_FIELD_LENGTH', 80);
/* PHP VERSION CHECK */
// PHP version requirement.
define('REQUIRED_PHP_VERSION', '5');
// Including necessary libraries.
require_once '../inc/lib/main_api.lib.php';
if (!function_exists('version_compare') || version_compare( phpversion(), REQUIRED_PHP_VERSION, '<')) {
$global_error_code = 1;
// Incorrect PHP version.
require '../inc/global_error_message.inc.php';
die();
}
check_php_version('../inc/');
/* INITIALIZATION SECTION */
ob_implicit_flush(true);
session_start();
// Including necessary libraries.
require_once '../inc/lib/main_api.lib.php';
require_once api_get_path(LIBRARY_PATH).'session.class.php';
require_once api_get_path(LIBRARY_PATH).'database.lib.php';
require_once api_get_path(LIBRARY_PATH).'log.class.php';

@ -1043,9 +1043,9 @@ function display_requirements($installType, $badUpdatePath, $updatePath = '', $u
echo '<div class="RequirementContent">';
echo '<table class="requirements">
<tr>
<td class="requirements-item">'.get_lang('PHPVersion').'>= '.MIN_PHP_VERSION.'</td>
<td class="requirements-item">'.get_lang('PHPVersion').'>= '.REQUIRED_PHP_VERSION.'</td>
<td class="requirements-value">';
if (phpversion() < MIN_PHP_VERSION) {
if (phpversion() < REQUIRED_PHP_VERSION) {
echo '<strong><font color="red">'.get_lang('PHPVersionError').'</font></strong>';
} else {
echo '<strong><font color="green">'.get_lang('PHPVersionOK'). ' '.phpversion().'</font></strong>';

Loading…
Cancel
Save