@@ -163,7 +133,7 @@ if (isset($_POST['language'])) {
$form->addElement('select_language', 'language', get_lang('Language'),null,array());
$buttons = '
-
+
';
$form->addElement('html',$buttons);
@@ -198,5 +168,4 @@ if (isset ($_GET['action'])) {
}
$form->setDefaults($defaults);
-$form->display();
-?>
\ No newline at end of file
+$form->display();
\ No newline at end of file
diff --git a/main/auth/inscription.php b/main/auth/inscription.php
index 05af7aa377..dfd41c1bcc 100644
--- a/main/auth/inscription.php
+++ b/main/auth/inscription.php
@@ -13,8 +13,6 @@ if (!empty($_POST['language'])) { //quick hack to adapt the registration form re
require_once '../inc/global.inc.php';
require_once api_get_path(CONFIGURATION_PATH).'profile.conf.php';
require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php';
-require_once api_get_path(LIBRARY_PATH).'legal.lib.php';
-//require_once api_get_path(LIBRARY_PATH).'custompages.lib.php';moved to autoload
if (!empty($_SESSION['user_language_choice'])) {
$user_selected_language = $_SESSION['user_language_choice'];
@@ -248,8 +246,6 @@ if ($display_all_form) {
}
}
-$form->addElement('style_submit_button', 'submit', get_lang('RegisterUser'), 'class="btn"');
-
if (isset($_SESSION['user_language_choice']) && $_SESSION['user_language_choice'] != '') {
$defaults['language'] = $_SESSION['user_language_choice'];
} else {
@@ -324,7 +320,6 @@ if (!CustomPages::enabled()) {
}
}
-
if (file_exists($home.'register_top_'.$user_selected_language.'.html')) {
$home_top_temp = @(string)file_get_contents($home.'register_top_'.$user_selected_language.'.html');
$open = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top_temp);
@@ -349,13 +344,12 @@ if (!CustomPages::enabled()) {
}
}
-
-
// Terms and conditions
if (api_get_setting('allow_terms_conditions') == 'true') {
$language = api_get_interface_language();
$language = api_get_language_id($language);
$term_preview = LegalManager::get_last_condition($language);
+
if (!$term_preview) {
//we load from the platform
$language = api_get_setting('platformLanguage');
@@ -367,6 +361,7 @@ if (api_get_setting('allow_terms_conditions') == 'true') {
$term_preview = LegalManager::get_last_condition($language);
}
}
+
// Version and language
$form->addElement('hidden', 'legal_accept_type', $term_preview['version'].':'.$term_preview['language_id']);
$form->addElement('hidden', 'legal_info', $term_preview['legal_id'].':'.$term_preview['language_id']);
@@ -374,25 +369,19 @@ if (api_get_setting('allow_terms_conditions') == 'true') {
if (isset($_SESSION['info_current_user'][1]) && isset($_SESSION['info_current_user'][2])) {
$form->addElement('hidden', 'login', $_SESSION['info_current_user'][1]);
$form->addElement('hidden', 'password', $_SESSION['info_current_user'][2]);
- }
+ }
if ($term_preview['type'] == 1) {
$form->addElement('checkbox', 'legal_accept', null, get_lang('IHaveReadAndAgree').'
'.get_lang('TermsAndConditions').'');
$form->addRule('legal_accept', get_lang('ThisFieldIsRequired'), 'required');
} else {
if (!empty($term_preview['content'])) {
- $preview = LegalManager::show_last_condition($term_preview);
- $term_preview = '
-
'.get_lang('TermsAndConditions').'
-
- '.$preview.'
-
-
-
';
- $form->addElement('html', $term_preview);
+ $preview = LegalManager::show_last_condition($term_preview);
+ $form->addElement('label', get_lang('TermsAndConditions'), $preview);
}
}
}
+$form->addElement('button', 'submit', get_lang('RegisterUser'));
if ($form->validate()) {
/*
@@ -413,7 +402,6 @@ if ($form->validate()) {
$values['username'] = $values['email'];
}
-
// creating a new user
$user_id = UserManager::create_user($values['firstname'], $values['lastname'], $values['status'], $values['email'], $values['username'], $values['pass1'], $values['official_code'], $values['language'], $values['phone'], $picture_uri);
@@ -508,6 +496,7 @@ if ($form->validate()) {
$emailsubject = get_lang('ApprovalForNewAccount',null,$values['language']).': '.$values['username'];
$emailbody = get_lang('ApprovalForNewAccount',null,$values['language'])."\n";
$emailbody .= get_lang('UserName',null,$values['language']).': '.$values['username']."\n";
+
if (api_is_western_name_order()) {
$emailbody .= get_lang('FirstName',null,$values['language']).': '.$values['firstname']."\n";
$emailbody .= get_lang('LastName',null,$values['language']).': '.$values['lastname']."\n";
@@ -532,9 +521,7 @@ if ($form->validate()) {
exit;
}
- /*
- SESSION REGISTERING
- */
+ /* SESSION REGISTERING */
$_user['firstName'] = stripslashes($values['firstname']);
$_user['lastName'] = stripslashes($values['lastname']);
$_user['mail'] = $values['email'];
@@ -551,9 +538,7 @@ if ($form->validate()) {
Session::write('user_last_login_datetime',$user_last_login_datetime);
- /*
- EMAIL NOTIFICATION
- */
+ /* EMAIL NOTIFICATION */
if (strpos($values['email'], '@') !== false) {
// Let us predefine some variables. Be sure to change the from address!
@@ -589,8 +574,7 @@ if ($form->validate()) {
$display_text.= '
'.get_lang('MailHasBeenSent',null,$_user['language']).'.
';
}
$button_text = '';
- if ($is_allowedCreateCourse) {
-
+ if ($is_allowedCreateCourse) {
$display_text .= '
'. get_lang('NowGoCreateYourCourse',null,$_user['language']). ".
\n";
$action_url = '../create_course/add_course.php';
$button_text = api_get_setting('course_validation') == 'true'
@@ -608,16 +592,16 @@ if ($form->validate()) {
// ?uidReset=true&uidReq=$_user['user_id']
$display_text .= '
'. "\n";
- if (CustomPages::enabled()) {
- CustomPages::display(CustomPages::REGISTRATION_FEEDBACK, array('info' => $display_text));
- }
+ if (CustomPages::enabled()) {
+ CustomPages::display(CustomPages::REGISTRATION_FEEDBACK, array('info' => $display_text));
+ }
echo $display_text;
} else {
// Custom pages
- if (CustomPages::enabled()) {
- CustomPages::display(CustomPages::REGISTRATION, array('form' => $form));
- } else {
- $form->display();
- }
+ if (CustomPages::enabled()) {
+ CustomPages::display(CustomPages::REGISTRATION, array('form' => $form));
+ } else {
+ $form->display();
+ }
}
Display :: display_footer();
\ No newline at end of file
diff --git a/main/inc/global.inc.php b/main/inc/global.inc.php
index 4529a41877..d14263cc6c 100644
--- a/main/inc/global.inc.php
+++ b/main/inc/global.inc.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';
diff --git a/main/inc/global_error_message.inc.php b/main/inc/global_error_message.inc.php
index 892ffb0dc1..c5cc23525d 100644
--- a/main/inc/global_error_message.inc.php
+++ b/main/inc/global_error_message.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 .= '
'.$read_installation_guide.'';
+ $IncorrectPhpVersionDescription .= '
'.$read_installation_guide.'';
}
$global_error_message['description'] = $IncorrectPhpVersionDescription;
break;
@@ -179,22 +178,24 @@ if (is_int($global_error_code) && $global_error_code > 0) {
-
diff --git a/main/inc/lib/diagnoser.lib.php b/main/inc/lib/diagnoser.lib.php
index 7fff8d2bfd..e592349560 100644
--- a/main/inc/lib/diagnoser.lib.php
+++ b/main/inc/lib/diagnoser.lib.php
@@ -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;
diff --git a/main/inc/lib/main_api.lib.php b/main/inc/lib/main_api.lib.php
index 6ee064519f..f3d4f28d70 100644
--- a/main/inc/lib/main_api.lib.php
+++ b/main/inc/lib/main_api.lib.php
@@ -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());
@@ -1653,7 +1654,7 @@ function api_set_anonymous() {
*/
function api_get_last_failure() {
global $api_failureList;
- return array_pop($api_failureList);
+ return $api_failureList[count($api_failureList) - 1];
}
/**
@@ -1700,7 +1701,7 @@ class api_failure {
function get_last_failure() {
global $api_failureList;
if (count($api_failureList) == 0) { return ''; }
- return array_pop($api_failureList);
+ return $api_failureList[count($api_failureList) - 1];
}
}
@@ -5803,3 +5804,15 @@ function block_course_item_locked_by_gradebook($item_id, $link_type, $course_cod
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;
+ }
+}
\ No newline at end of file
diff --git a/main/install/index.php b/main/install/index.php
index f3a0850b40..c26f3117e8 100644
--- a/main/install/index.php
+++ b/main/install/index.php
@@ -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';
diff --git a/main/install/install.lib.php b/main/install/install.lib.php
index cac631d483..67f432d599 100755
--- a/main/install/install.lib.php
+++ b/main/install/install.lib.php
@@ -1043,9 +1043,9 @@ function display_requirements($installType, $badUpdatePath, $updatePath = '', $u
echo '
';
echo '
- '.get_lang('PHPVersion').'>= '.MIN_PHP_VERSION.' |
+ '.get_lang('PHPVersion').'>= '.REQUIRED_PHP_VERSION.' |
';
- if (phpversion() < MIN_PHP_VERSION) {
+ if (phpversion() < REQUIRED_PHP_VERSION) {
echo ''.get_lang('PHPVersionError').'';
} else {
echo ''.get_lang('PHPVersionOK'). ' '.phpversion().'';
|