From 02d9c8a69478ffd0d3efe7443a4628e21a2aaa37 Mon Sep 17 00:00:00 2001 From: Ivan Tcholakov Date: Sun, 14 Feb 2010 05:50:54 +0200 Subject: [PATCH 01/12] Feature #272 - Reworks for some functions to make them stable against non-string input parameters. --- main/inc/lib/internationalization.lib.php | 45 ++++++++++--------- .../lib/internationalization_internal.lib.php | 39 ++++++++-------- 2 files changed, 45 insertions(+), 39 deletions(-) diff --git a/main/inc/lib/internationalization.lib.php b/main/inc/lib/internationalization.lib.php index 14460477f3..a74ffe5aae 100755 --- a/main/inc/lib/internationalization.lib.php +++ b/main/inc/lib/internationalization.lib.php @@ -3243,10 +3243,11 @@ function api_is_valid_utf8(&$string) { // wrongly detected as UTF-8. Possibly, there would be problems with other // languages too. An alternative implementation will be used. - $len = api_byte_count($string); + $str = (string)$string; + $len = api_byte_count($str); $i = 0; while ($i < $len) { - $byte1 = ord($string[$i++]); // Here the current character begins. Its size is + $byte1 = ord($str[$i++]); // Here the current character begins. Its size is // determined by the senior bits in the first byte. if (($byte1 & 0x80) == 0x00) { // 0xxxxxxx @@ -3267,7 +3268,7 @@ function api_is_valid_utf8(&$string) { return false; // Here the string ends unexpectedly. } - if (!((ord($string[$i++]) & 0xC0) == 0x80)) + if (!((ord($str[$i++]) & 0xC0) == 0x80)) return false; // Invalid second byte, invalid string. } @@ -3280,13 +3281,13 @@ function api_is_valid_utf8(&$string) { if ($i == $len) { return false; // Unexpected end of the string. } - if (!((ord($string[$i++]) & 0xC0) == 0x80)) { + if (!((ord($str[$i++]) & 0xC0) == 0x80)) { return false; // Invalid second byte. } if ($i == $len) { return false; // Unexpected end of the string. } - if (!((ord($string[$i++]) & 0xC0) == 0x80)) { + if (!((ord($str[$i++]) & 0xC0) == 0x80)) { return false; // Invalid third byte, invalid string. } } @@ -3300,19 +3301,19 @@ function api_is_valid_utf8(&$string) { if ($i == $len) { return false; } - if (!((ord($string[$i++]) & 0xC0) == 0x80)) { + if (!((ord($str[$i++]) & 0xC0) == 0x80)) { return false; } if ($i == $len) { return false; } - if (!((ord($string[$i++]) & 0xC0) == 0x80)) { + if (!((ord($str[$i++]) & 0xC0) == 0x80)) { return false; } if ($i == $len) { return false; } - if (!((ord($string[$i++]) & 0xC0) == 0x80)) { + if (!((ord($str[$i++]) & 0xC0) == 0x80)) { return false; } } @@ -3326,25 +3327,25 @@ function api_is_valid_utf8(&$string) { if ($i == $len) { return false; } - if (!((ord($string[$i++]) & 0xC0) == 0x80)) { + if (!((ord($str[$i++]) & 0xC0) == 0x80)) { return false; } if ($i == $len) { return false; } - if (!((ord($string[$i++]) & 0xC0) == 0x80)) { + if (!((ord($str[$i++]) & 0xC0) == 0x80)) { return false; } if ($i == $len) { return false; } - if (!((ord($string[$i++]) & 0xC0) == 0x80)) { + if (!((ord($str[$i++]) & 0xC0) == 0x80)) { return false; } if ($i == $len) { return false; } - if (!((ord($string[$i++]) & 0xC0) == 0x80)) { + if (!((ord($str[$i++]) & 0xC0) == 0x80)) { return false; } } @@ -3358,31 +3359,31 @@ function api_is_valid_utf8(&$string) { if ($i == $len) { return false; } - if (!((ord($string[$i++]) & 0xC0) == 0x80)) { + if (!((ord($str[$i++]) & 0xC0) == 0x80)) { return false; } if ($i == $len) { return false; } - if (!((ord($string[$i++]) & 0xC0) == 0x80)) { + if (!((ord($str[$i++]) & 0xC0) == 0x80)) { return false; } if ($i == $len) { return false; } - if (!((ord($string[$i++]) & 0xC0) == 0x80)) { + if (!((ord($str[$i++]) & 0xC0) == 0x80)) { return false; } if ($i == $len) { return false; } - if (!((ord($string[$i++]) & 0xC0) == 0x80)) { + if (!((ord($str[$i++]) & 0xC0) == 0x80)) { return false; } if ($i == $len) { return false; } - if (!((ord($string[$i++]) & 0xC0) == 0x80)) { + if (!((ord($str[$i++]) & 0xC0) == 0x80)) { return false; } } @@ -3428,17 +3429,21 @@ function api_is_valid_ascii(&$string) { * @link http://php.net/manual/en/function.str-getcsv.php (exists as of PHP 5 >= 5.3.0) */ function & api_str_getcsv(& $string, $delimiter = ',', $enclosure = '"', $escape = '\\') { + $delimiter = (string)$delimiter; if (api_byte_count($delimiter) > 1) { $delimiter = $delimiter[1]; } + $enclosure = (string)$enclosure; if (api_byte_count($enclosure) > 1) { $enclosure = $enclosure[1]; } + $escape = (string)$escape; if (api_byte_count($escape) > 1) { $escape = $escape[1]; } - $len = api_byte_count($string); + $str = (string)$string; + $len = api_byte_count($str); $enclosed = false; $escaped = false; $value = ''; $result = array(); for ($i = 0; $i < $len; $i++) { - $char = $string[$i]; + $char = $str[$i]; if ($char == $escape) { if (!$escaped) { $escaped = true; @@ -3448,7 +3453,7 @@ function & api_str_getcsv(& $string, $delimiter = ',', $enclosure = '"', $escape $escaped = false; switch ($char) { case $enclosure: - if ($enclosed && $string[$i + 1] == $enclosure) { + if ($enclosed && $str[$i + 1] == $enclosure) { $value .= $char; $i++; } else { diff --git a/main/inc/lib/internationalization_internal.lib.php b/main/inc/lib/internationalization_internal.lib.php index b8f7fb632b..c9dd95e18a 100755 --- a/main/inc/lib/internationalization_internal.lib.php +++ b/main/inc/lib/internationalization_internal.lib.php @@ -331,45 +331,46 @@ function _api_clean_person_name($person_name) { * @param string $from_encoding The encoding that $string is being converted from. * @return string Returns the converted string. */ -function _api_convert_encoding($string, $to_encoding, $from_encoding) { +function _api_convert_encoding(&$string, $to_encoding, $from_encoding) { + $str = (string)$string; static $character_map = array(); static $utf8_compatible = array('UTF-8', 'US-ASCII'); - if (empty($string)) { - return $string; + if (empty($str)) { + return $str; } $to_encoding = api_refine_encoding_id($to_encoding); $from_encoding = api_refine_encoding_id($from_encoding); if (api_equal_encodings($to_encoding, $from_encoding)) { - return $string; + return $str; } if ($to_encoding == 'HTML-ENTITIES') { - return api_htmlentities($string, ENT_QUOTES, $from_encoding); + return api_htmlentities($str, ENT_QUOTES, $from_encoding); } if ($from_encoding == 'HTML-ENTITIES') { - return api_html_entity_decode($string, ENT_QUOTES, $to_encoding); + return api_html_entity_decode($str, ENT_QUOTES, $to_encoding); } $to = _api_get_character_map_name($to_encoding); $from = _api_get_character_map_name($from_encoding); if (empty($to) || empty($from) || $to == $from || (in_array($to, $utf8_compatible) && in_array($from, $utf8_compatible))) { - return $string; + return $str; } if (!isset($character_map[$to])) { $character_map[$to] = &_api_parse_character_map($to); } if ($character_map[$to] === false) { - return $string; + return $str; } if (!isset($character_map[$from])) { $character_map[$from] = &_api_parse_character_map($from); } if ($character_map[$from] === false) { - return $string; + return $str; } if ($from != 'UTF-8') { - $len = api_byte_count($string); + $len = api_byte_count($str); $codepoints = array(); for ($i = 0; $i < $len; $i++) { - $ord = ord($string[$i]); + $ord = ord($str[$i]); if ($ord > 127) { if (isset($character_map[$from]['local'][$ord])) { $codepoints[] = $character_map[$from]['local'][$ord]; @@ -381,7 +382,7 @@ function _api_convert_encoding($string, $to_encoding, $from_encoding) { } } } else { - $codepoints = _api_utf8_to_unicode($string); + $codepoints = _api_utf8_to_unicode($str); } if ($to != 'UTF-8') { foreach ($codepoints as $i => &$codepoint) { @@ -395,11 +396,11 @@ function _api_convert_encoding($string, $to_encoding, $from_encoding) { $codepoint = chr($codepoint); } } - $string = implode($codepoints); + $str = implode($codepoints); } else { - $string = _api_utf8_from_unicode($codepoints); + $str = _api_utf8_from_unicode($codepoints); } - return $string; + return $str; } /** @@ -468,16 +469,16 @@ function &_api_parse_character_map($name) { * @link http://hsivonen.iki.fi/php-utf8/ * @author Ivan Tcholakov, August 2009, adaptation for the Dokeos LMS. */ -function _api_utf8_to_unicode($string) { - if (!is_string($string)) { $string = (string)$string; } // A quick workaround after testing. +function _api_utf8_to_unicode(&$string) { + $str = (string)$string; $state = 0; // cached expected number of octets after the current octet // until the beginning of the next UTF8 character sequence $codepoint = 0; // cached Unicode character $bytes = 1; // cached expected number of octets in the current sequence $result = array(); - $len = api_byte_count($string); + $len = api_byte_count($str); for ($i = 0; $i < $len; $i++) { - $byte = ord($string[$i]); + $byte = ord($str[$i]); if ($state == 0) { // When state is zero we expect either a US-ASCII character or a multi-octet sequence. if (0 == (0x80 & ($byte))) { From a14751f441ec0bfc3c14ee2df1eca1947fae261c Mon Sep 17 00:00:00 2001 From: Ivan Tcholakov Date: Sun, 14 Feb 2010 13:14:41 +0200 Subject: [PATCH 02/12] Feature #272 - Corrections for the function api_display_language_form(). --- main/inc/lib/main_api.lib.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/main/inc/lib/main_api.lib.php b/main/inc/lib/main_api.lib.php index 13c9e260fe..b96167bce4 100755 --- a/main/inc/lib/main_api.lib.php +++ b/main/inc/lib/main_api.lib.php @@ -2557,20 +2557,21 @@ function api_get_languages_combo($name = 'language') { * @return void Display the box directly */ function api_display_language_form($hide_if_no_choice = false) { - $platformLanguage = api_get_setting('platformLanguage'); - $dirname = api_get_path(SYS_PATH).'main/lang/'; // TODO: this line is probably no longer needed + // retrieve a complete list of all the languages. $language_list = api_get_languages(); if (count($language_list['name']) <= 1 && $hide_if_no_choice) { return; //don't show any form } + // the the current language of the user so that his/her language occurs as selected in the dropdown menu if (isset($_SESSION['user_language_choice'])) { $user_selected_language = $_SESSION['user_language_choice']; } - if (!isset($user_selected_language)) { - $user_selected_language = $platformLanguage; + if (empty($user_selected_language)) { + $user_selected_language = api_get_setting('platformLanguage'); } + $original_languages = $language_list['name']; $folder = $language_list['folder']; // this line is probably no longer needed ?> From 7b1d7d0922d3ffb07707c3cd5608d2b4e8624a89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Carlos=20Ra=C3=B1a?= Date: Sun, 14 Feb 2010 13:26:46 +0100 Subject: [PATCH 03/12] protect some folders --- plugin/dashboard/block_course/css/index.html | 8 ++++++++ plugin/dashboard/block_course/index.html | 8 ++++++++ plugin/dashboard/block_session/css/index.html | 8 ++++++++ plugin/dashboard/block_session/index.html | 8 ++++++++ plugin/dashboard/block_student/css/index.html | 8 ++++++++ plugin/dashboard/block_student/index.html | 8 ++++++++ plugin/dashboard/block_teacher/css/index.html | 8 ++++++++ plugin/dashboard/block_teacher/index.html | 8 ++++++++ plugin/dashboard/index.html | 8 ++++++++ plugin/search/client/index.html | 8 ++++++++ plugin/search/client/www/index.html | 8 ++++++++ plugin/search/server/cron.d/index.html | 8 ++++++++ plugin/search/server/etc/index.html | 8 ++++++++ plugin/search/server/www/index.html | 8 ++++++++ 14 files changed, 112 insertions(+) create mode 100644 plugin/dashboard/block_course/css/index.html create mode 100644 plugin/dashboard/block_course/index.html create mode 100644 plugin/dashboard/block_session/css/index.html create mode 100644 plugin/dashboard/block_session/index.html create mode 100644 plugin/dashboard/block_student/css/index.html create mode 100644 plugin/dashboard/block_student/index.html create mode 100644 plugin/dashboard/block_teacher/css/index.html create mode 100644 plugin/dashboard/block_teacher/index.html create mode 100644 plugin/dashboard/index.html create mode 100644 plugin/search/client/index.html create mode 100644 plugin/search/client/www/index.html create mode 100644 plugin/search/server/cron.d/index.html create mode 100644 plugin/search/server/etc/index.html create mode 100644 plugin/search/server/www/index.html diff --git a/plugin/dashboard/block_course/css/index.html b/plugin/dashboard/block_course/css/index.html new file mode 100644 index 0000000000..8e464d8ce3 --- /dev/null +++ b/plugin/dashboard/block_course/css/index.html @@ -0,0 +1,8 @@ + + + + + +
+ + \ No newline at end of file diff --git a/plugin/dashboard/block_course/index.html b/plugin/dashboard/block_course/index.html new file mode 100644 index 0000000000..8e464d8ce3 --- /dev/null +++ b/plugin/dashboard/block_course/index.html @@ -0,0 +1,8 @@ + + + + + +
+ + \ No newline at end of file diff --git a/plugin/dashboard/block_session/css/index.html b/plugin/dashboard/block_session/css/index.html new file mode 100644 index 0000000000..8e464d8ce3 --- /dev/null +++ b/plugin/dashboard/block_session/css/index.html @@ -0,0 +1,8 @@ + + + + + +
+ + \ No newline at end of file diff --git a/plugin/dashboard/block_session/index.html b/plugin/dashboard/block_session/index.html new file mode 100644 index 0000000000..8e464d8ce3 --- /dev/null +++ b/plugin/dashboard/block_session/index.html @@ -0,0 +1,8 @@ + + + + + +
+ + \ No newline at end of file diff --git a/plugin/dashboard/block_student/css/index.html b/plugin/dashboard/block_student/css/index.html new file mode 100644 index 0000000000..8e464d8ce3 --- /dev/null +++ b/plugin/dashboard/block_student/css/index.html @@ -0,0 +1,8 @@ + + + + + +
+ + \ No newline at end of file diff --git a/plugin/dashboard/block_student/index.html b/plugin/dashboard/block_student/index.html new file mode 100644 index 0000000000..8e464d8ce3 --- /dev/null +++ b/plugin/dashboard/block_student/index.html @@ -0,0 +1,8 @@ + + + + + +
+ + \ No newline at end of file diff --git a/plugin/dashboard/block_teacher/css/index.html b/plugin/dashboard/block_teacher/css/index.html new file mode 100644 index 0000000000..8e464d8ce3 --- /dev/null +++ b/plugin/dashboard/block_teacher/css/index.html @@ -0,0 +1,8 @@ + + + + + +
+ + \ No newline at end of file diff --git a/plugin/dashboard/block_teacher/index.html b/plugin/dashboard/block_teacher/index.html new file mode 100644 index 0000000000..8e464d8ce3 --- /dev/null +++ b/plugin/dashboard/block_teacher/index.html @@ -0,0 +1,8 @@ + + + + + +
+ + \ No newline at end of file diff --git a/plugin/dashboard/index.html b/plugin/dashboard/index.html new file mode 100644 index 0000000000..8e464d8ce3 --- /dev/null +++ b/plugin/dashboard/index.html @@ -0,0 +1,8 @@ + + + + + +
+ + \ No newline at end of file diff --git a/plugin/search/client/index.html b/plugin/search/client/index.html new file mode 100644 index 0000000000..8e464d8ce3 --- /dev/null +++ b/plugin/search/client/index.html @@ -0,0 +1,8 @@ + + + + + +
+ + \ No newline at end of file diff --git a/plugin/search/client/www/index.html b/plugin/search/client/www/index.html new file mode 100644 index 0000000000..8e464d8ce3 --- /dev/null +++ b/plugin/search/client/www/index.html @@ -0,0 +1,8 @@ + + + + + +
+ + \ No newline at end of file diff --git a/plugin/search/server/cron.d/index.html b/plugin/search/server/cron.d/index.html new file mode 100644 index 0000000000..8e464d8ce3 --- /dev/null +++ b/plugin/search/server/cron.d/index.html @@ -0,0 +1,8 @@ + + + + + +
+ + \ No newline at end of file diff --git a/plugin/search/server/etc/index.html b/plugin/search/server/etc/index.html new file mode 100644 index 0000000000..8e464d8ce3 --- /dev/null +++ b/plugin/search/server/etc/index.html @@ -0,0 +1,8 @@ + + + + + +
+ + \ No newline at end of file diff --git a/plugin/search/server/www/index.html b/plugin/search/server/www/index.html new file mode 100644 index 0000000000..8e464d8ce3 --- /dev/null +++ b/plugin/search/server/www/index.html @@ -0,0 +1,8 @@ + + + + + +
+ + \ No newline at end of file From 0b86484fb33bcb78c4727488a8c1b84958ed17e5 Mon Sep 17 00:00:00 2001 From: Ivan Tcholakov Date: Sun, 14 Feb 2010 14:55:15 +0200 Subject: [PATCH 04/12] Feature #347 - The strange, unused and undocumented constant REL_SYS_PATH inside the function api_get_path() has been removed. This is a partial fix for a problem reported by krikrizzz, see http://www.chamilo.org/en/node/190 --- main/inc/lib/main_api.lib.php | 13 ++++++------- tests/main/inc/lib/main_api.lib.test.php | 1 - 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/main/inc/lib/main_api.lib.php b/main/inc/lib/main_api.lib.php index b96167bce4..c3032b930f 100755 --- a/main/inc/lib/main_api.lib.php +++ b/main/inc/lib/main_api.lib.php @@ -331,7 +331,6 @@ function api_get_path($path_type, $path = null) { WEB_PATH => '', SYS_PATH => '', REL_PATH => '', - REL_SYS_PATH => '', WEB_SERVER_ROOT_PATH => '', SYS_SERVER_ROOT_PATH => '', WEB_COURSE_PATH => '', @@ -3137,11 +3136,11 @@ function api_chmod_R($path, $filemode) { */ function parse_info_file($filename) { $info = array(); - + if (!file_exists($filename)) { return $info; } - + $data = file_get_contents($filename); if (preg_match_all(' @^\s* # Start at the beginning of a line, ignoring leading whitespace @@ -3163,12 +3162,12 @@ function api_chmod_R($path, $filemode) { $$var = isset($match[++$i]) ? $match[$i] : ''; } $value = stripslashes(substr($value1, 1, -1)) . stripslashes(substr($value2, 1, -1)) . $value3; - + // Parse array syntax $keys = preg_split('/\]?\[/', rtrim($key, ']')); $last = array_pop($keys); $parent = &$info; - + // Create nested arrays foreach ($keys as $key) { if ($key == '') { @@ -3179,12 +3178,12 @@ function api_chmod_R($path, $filemode) { } $parent = &$parent[$key]; } - + // Handle PHP constants if (defined($value)) { $value = constant($value); } - + // Insert actual value if ($last == '') { $last = count($parent); diff --git a/tests/main/inc/lib/main_api.lib.test.php b/tests/main/inc/lib/main_api.lib.test.php index 3562ae4d25..550f84239e 100755 --- a/tests/main/inc/lib/main_api.lib.test.php +++ b/tests/main/inc/lib/main_api.lib.test.php @@ -49,7 +49,6 @@ class TestMainApi extends UnitTestCase { WEB_PATH => '', SYS_PATH => '', REL_PATH => '', - REL_SYS_PATH => '', WEB_SERVER_ROOT_PATH => '', SYS_SERVER_ROOT_PATH => '', WEB_COURSE_PATH => '', From 1ad6d41aec507bb4dd325e9b756e191ac2eebec9 Mon Sep 17 00:00:00 2001 From: Ivan Tcholakov Date: Sun, 14 Feb 2010 16:02:29 +0200 Subject: [PATCH 05/12] Feature #272 - Installation scripts: Modernizing some code in install_db.inc.php. --- main/install/install_db.inc.php | 56 +++++++++++++++------------------ 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/main/install/install_db.inc.php b/main/install/install_db.inc.php index a7bad26ad3..8c78363b09 100755 --- a/main/install/install_db.inc.php +++ b/main/install/install_db.inc.php @@ -2,7 +2,7 @@ /* For licensing terms, see /chamilo_license.txt */ /** ============================================================================== -* Install the Dokeos database +* Install the Chamilo database * Notice : This script has to be included by index.php * * @package chamilo.install @@ -17,7 +17,7 @@ require_once 'install_upgrade.lib.php'; ============================================================================== */ -//this page can only be access through including from the install script. +// This page can only be access through including from the install script. if (!defined('DOKEOS_INSTALL')) { echo 'You are not allowed here!'; @@ -53,9 +53,7 @@ Database::query("SET SESSION character_set_server='utf8';"); Database::query("SET SESSION collation_server='utf8_general_ci';"); Database::query("SET CHARACTER SET 'utf8';"); -if ($urlForm[strlen($urlForm) - 1] != '/') { - $urlForm = $urlForm.'/'; -} +$urlForm = api_add_trailing_slash($urlForm); switch ($encryptPassForm) { case 'md5' : @@ -69,36 +67,34 @@ switch ($encryptPassForm) { break; } -$dbPrefixForm = eregi_replace('[^a-z0-9_-]', '', $dbPrefixForm); - -$dbNameForm = eregi_replace('[^a-z0-9_-]', '', $dbNameForm); -$dbStatsForm = eregi_replace('[^a-z0-9_-]', '', $dbStatsForm); -$dbUserForm = eregi_replace('[^a-z0-9_-]', '', $dbUserForm); +$dbPrefixForm = preg_replace('/[^a-zA-Z0-9_-]/', '', $dbPrefixForm); -if (!empty($dbPrefixForm) && !ereg('^'.$dbPrefixForm, $dbNameForm)) { +$dbNameForm = preg_replace('/[^a-zA-Z0-9_-]/', '', $dbNameForm); +if (!empty($dbPrefixForm) && strpos($dbNameForm, $dbPrefixForm) !== 0) { $dbNameForm = $dbPrefixForm.$dbNameForm; } -if (!empty($dbPrefixForm) && !ereg('^'.$dbPrefixForm, $dbStatsForm)) { +$dbStatsForm = preg_replace('/[^a-zA-Z0-9_-]/', '', $dbStatsForm); +if (!empty($dbPrefixForm) && strpos($dbStatsForm, $dbPrefixForm) !== 0) { $dbStatsForm = $dbPrefixForm.$dbStatsForm; } -if (!empty($dbPrefixForm) && !ereg('^'.$dbPrefixForm, $dbUserForm)) { +$dbUserForm = preg_replace('/[^a-zA-Z0-9_-]/', '', $dbUserForm); +if (!empty($dbPrefixForm) && strpos($dbUserForm, $dbPrefixForm) !== 0) { $dbUserForm = $dbPrefixForm.$dbUserForm; } $mysqlMainDb = $dbNameForm; -$mysqlStatsDb = $dbStatsForm; -$mysqlUserDb = $dbUserForm; - if (empty($mysqlMainDb) || $mysqlMainDb == 'mysql' || $mysqlMainDb == $dbPrefixForm) { $mysqlMainDb = $dbPrefixForm.'main'; } +$mysqlStatsDb = $dbStatsForm; if (empty($mysqlStatsDb) || $mysqlStatsDb == 'mysql' || $mysqlStatsDb == $dbPrefixForm) { $mysqlStatsDb = $dbPrefixForm.'stats'; } +$mysqlUserDb = $dbUserForm; if (empty($mysqlUserDb) || $mysqlUserDb == 'mysql' || $mysqlUserDb == $dbPrefixForm) { $mysqlUserDb = $dbPrefixForm.'user'; } @@ -113,13 +109,13 @@ if (!$singleDbForm) { } Database::query("CREATE DATABASE IF NOT EXISTS `$mysqlMainDb`") or die(Database::error()); -if($mysqlStatsDb == $mysqlMainDb && $mysqlUserDb == $mysqlMainDb) { +if ($mysqlStatsDb == $mysqlMainDb && $mysqlUserDb == $mysqlMainDb) { $singleDbForm = true; } /** -* CREATING THE STATISTICS DATABASE -*/ + * CREATING THE STATISTICS DATABASE + */ if ($mysqlStatsDb != $mysqlMainDb) { if (!$singleDbForm) { // multi DB mode AND tracking has its own DB so create it @@ -132,8 +128,8 @@ if ($mysqlStatsDb != $mysqlMainDb) { } /** -* CREATING THE USER DATABASE -*/ + * CREATING THE USER DATABASE + */ if ($mysqlUserDb != $mysqlMainDb) { if (!$singleDbForm) { // multi DB mode AND user data has its own DB so create it @@ -145,15 +141,15 @@ if ($mysqlUserDb != $mysqlMainDb) { } } -include '../lang/english/create_course.inc.php'; +include api_get_path(SYS_LANG_PATH).'english/create_course.inc.php'; if ($languageForm != 'english') { - include '../lang/'.$languageForm.'/create_course.inc.php'; + include api_get_path(SYS_LANG_PATH).$languageForm.'/create_course.inc.php'; } /** -* creating the tables of the main database -*/ + * creating the tables of the main database + */ Database::select_db($mysqlMainDb) or die(Database::error()); $installation_settings['{ORGANISATIONNAME}'] = $institutionForm; @@ -174,8 +170,8 @@ $installation_settings['{HASHFUNCTIONMODE}'] = $encryptPassForm; load_main_database($installation_settings); /** -* creating the tables of the tracking database -*/ + * creating the tables of the tracking database + */ Database::select_db($mysqlStatsDb) or die(Database::error()); @@ -185,9 +181,9 @@ $track_countries_table = "track_c_countries"; fill_track_countries_table($track_countries_table); /** -* creating the tables of the USER database -* this is where the personal agenda items are storen, the user defined course categories (sorting of my courses) -*/ + * creating the tables of the USER database + * this is where the personal agenda items are storen, the user defined course categories (sorting of my courses) + */ Database::select_db($mysqlUserDb) or die(Database::error()); From dab06263fd2d04323f48fddd72819a6b3720f916 Mon Sep 17 00:00:00 2001 From: Ivan Tcholakov Date: Sun, 14 Feb 2010 17:16:47 +0200 Subject: [PATCH 06/12] Feature #272 - Installation scripts: Reworks, cleaning. --- main/install/index.php | 17 +++-------------- main/install/install_db.inc.php | 4 ++-- main/install/install_functions.inc.php | 20 ++++++++++---------- main/install/install_upgrade.lib.php | 6 +++--- 4 files changed, 18 insertions(+), 29 deletions(-) diff --git a/main/install/index.php b/main/install/index.php index c871e75f97..1fbaa09b11 100755 --- a/main/install/index.php +++ b/main/install/index.php @@ -40,7 +40,6 @@ if (!function_exists('version_compare') || version_compare( phpversion(), REQUIR session_start(); // Including necessary core libraries. -//@include '../inc/installedVersion.inc.php'; //TODO: This line is to be removed. require '../inc/lib/main_api.lib.php'; require api_get_path(LIBRARY_PATH).'database.lib.php'; @@ -155,14 +154,7 @@ if ($_POST['step2_install'] || $_POST['step2_update_8'] || $_POST['step2_update_ $installType = 'update'; if ($_POST['step2_update_8']) { $emptyUpdatePath = false; - if (empty($_POST['updatePath'])) { - $proposedUpdatePath = $_SERVER['DOCUMENT_ROOT']; - } else { - $proposedUpdatePath = $_POST['updatePath']; - } - if (substr($proposedUpdatePath,-1) != '/') { - $proposedUpdatePath .= '/'; - } + $proposedUpdatePath = api_add_trailing_slash(empty($_POST['updatePath']) ? $_SERVER['DOCUMENT_ROOT'] : $_POST['updatePath']); if (file_exists($proposedUpdatePath)) { if (in_array($my_old_version, $update_from_version_8)) { $_POST['step2'] = 1; @@ -177,10 +169,7 @@ if ($_POST['step2_install'] || $_POST['step2_update_8'] || $_POST['step2_update_ $_POST['step1'] = 1; } else { $emptyUpdatePath = false; - if (substr($_POST['updatePath'], -1) != '/') { - $_POST['updatePath'] .= '/'; - } - + $_POST['updatePath'] = api_add_trailing_slash($_POST['updatePath']); if (file_exists($_POST['updatePath'])) { //1.6.x $my_old_version = get_config_param('clarolineVersion', $_POST['updatePath']); @@ -547,7 +536,7 @@ if ($_POST['step2']) { } display_configuration_settings_form($installType, $urlForm, $languageForm, $emailForm, $adminFirstName, $adminLastName, $adminPhoneForm, $campusForm, $institutionForm, $institutionUrlForm, $encryptPassForm, $allowSelfReg, $allowSelfRegProf, $loginForm, $passForm); -} elseif($_POST['step5']) { +} elseif ($_POST['step5']) { //STEP 6 : LAST CHECK BEFORE INSTALL ?> diff --git a/main/install/install_db.inc.php b/main/install/install_db.inc.php index 8c78363b09..a8f63d2ab7 100755 --- a/main/install/install_db.inc.php +++ b/main/install/install_db.inc.php @@ -156,8 +156,8 @@ $installation_settings['{ORGANISATIONNAME}'] = $institutionForm; $installation_settings['{ORGANISATIONURL}'] = $institutionUrlForm; $installation_settings['{CAMPUSNAME}'] = $campusForm; $installation_settings['{PLATFORMLANGUAGE}'] = $languageForm; -$installation_settings['{ALLOWSELFREGISTRATION}'] = trueFalse($allowSelfReg); -$installation_settings['{ALLOWTEACHERSELFREGISTRATION}'] = trueFalse($allowSelfRegProf); +$installation_settings['{ALLOWSELFREGISTRATION}'] = true_false($allowSelfReg); +$installation_settings['{ALLOWTEACHERSELFREGISTRATION}'] = true_false($allowSelfRegProf); $installation_settings['{ADMINLASTNAME}'] = $adminLastName; $installation_settings['{ADMINFIRSTNAME}'] = $adminFirstName; $installation_settings['{ADMINLOGIN}'] = $loginForm; diff --git a/main/install/install_functions.inc.php b/main/install/install_functions.inc.php index b156151c0d..ea8d344e5b 100755 --- a/main/install/install_functions.inc.php +++ b/main/install/install_functions.inc.php @@ -69,8 +69,7 @@ function check_php_setting($php_setting, $recommended_value, $return_success = f * @author Joomla */ function get_php_setting($val) { - $r = ini_get($val) == '1' ? 1 : 0; - return $r ? 'ON' : 'OFF'; + return ini_get($val) == '1' ? 'ON' : 'OFF'; } /** @@ -95,7 +94,7 @@ function check_writable($folder, $suggestion = false) { * @return string the string "true" or "false" * @author Christophe Gesché */ -function trueFalse($var) { +function true_false($var) { return $var ? 'true' : 'false'; } @@ -136,14 +135,16 @@ function get_config_param($param, $updatePath = '') { $updatePath = realpath($updatePath).'/'; $updateFromInstalledVersionFile = ''; - if (empty($updateFromConfigFile)) { //if update from previous install was requested + if (empty($updateFromConfigFile)) { + //if update from previous install was requested //try to recover old config file from dokeos 1.8.x if (file_exists($updatePath.'main/inc/conf/configuration.php')) { - $updateFromConfigFile='main/inc/conf/configuration.php'; + $updateFromConfigFile = 'main/inc/conf/configuration.php'; } elseif (file_exists($updatePath.'claroline/inc/conf/claro_main.conf.php')) { - $updateFromConfigFile='claroline/inc/conf/claro_main.conf.php'; - } else { //give up recovering - error_log('Could not find config file in '.$updatePath.' in get_config_param()',0); + $updateFromConfigFile = 'claroline/inc/conf/claro_main.conf.php'; + } else { + //give up recovering + error_log('Could not find config file in '.$updatePath.' in get_config_param()', 0); return null; } } @@ -288,8 +289,7 @@ function get_language_folder_list($dirname) { */ function display_language_selection_box() { //get language list - $dirname = '../lang/'; // TODO: Check api_get_path() and use it. - $language_list = get_language_folder_list($dirname); + $language_list = get_language_folder_list(api_get_path(SYS_LANG_PATH)); sort($language_list); //Reduce the number of languages shown to only show those with higher than 90% translation in DLTT //This option can be easily removed later on. The aim is to test people response to less choice diff --git a/main/install/install_upgrade.lib.php b/main/install/install_upgrade.lib.php index c2a9b9700e..dc6325fd6f 100755 --- a/main/install/install_upgrade.lib.php +++ b/main/install/install_upgrade.lib.php @@ -104,8 +104,8 @@ function write_dokeos_config_file($path) { $config['{DATABASE_HOST}'] = $dbHostForm; $config['{DATABASE_USER}'] = $dbUsernameForm; $config['{DATABASE_PASSWORD}'] = $dbPassForm; - $config['TRACKING_ENABLED'] = trueFalse($enableTrackingForm); - $config['SINGLE_DATABASE'] = trueFalse($singleDbForm); + $config['TRACKING_ENABLED'] = true_false($enableTrackingForm); + $config['SINGLE_DATABASE'] = true_false($singleDbForm); $config['{COURSE_TABLE_PREFIX}'] = ($singleDbForm ? 'crs_' : ''); $config['{DATABASE_GLUE}'] = ($singleDbForm ? '_' : '`.`'); $config['{DATABASE_PREFIX}'] = $dbPrefixForm; @@ -122,7 +122,7 @@ function write_dokeos_config_file($path) { $config['SESSION_LIFETIME'] = $session_lifetime; $config['{NEW_VERSION}'] = $new_version; - $config['NEW_VERSION_STABLE'] = trueFalse($new_version_stable); + $config['NEW_VERSION_STABLE'] = true_false($new_version_stable); foreach ($config as $key => $value) { $content = str_replace($key, $value, $content); From 821f3995bcfe2c530c09d65cf524d155e08f7ec3 Mon Sep 17 00:00:00 2001 From: Ivan Tcholakov Date: Sun, 14 Feb 2010 18:27:30 +0200 Subject: [PATCH 07/12] Feature #347 - A constant in the instalaltion scripts has been renamed ( SYSTEM_INSTALLATION ). --- main/install/index.php | 2 +- main/install/install_db.inc.php | 2 +- main/install/install_files.inc.php | 2 +- main/install/update-db-1.6.x-1.8.0.inc.php | 10 +++++----- main/install/update-db-1.8.0-1.8.2.inc.php | 8 ++++---- main/install/update-db-1.8.2-1.8.3.inc.php | 8 ++++---- main/install/update-db-1.8.3-1.8.4.inc.php | 8 ++++---- main/install/update-db-1.8.4-1.8.5.inc.php | 8 ++++---- main/install/update-db-1.8.5-1.8.6.inc.php | 8 ++++---- main/install/update-db-1.8.6-1.8.6.1.inc.php | 8 ++++---- main/install/update-db-1.8.6.1-1.8.6.2.inc.php | 8 ++++---- main/install/update-db-1.8.6.2-1.8.7.inc.php | 8 ++++---- main/install/update-files-1.6.x-1.8.0.inc.php | 8 ++++---- main/install/update-files-1.8.3-1.8.4.inc.php | 2 +- main/install/update-files-1.8.4-1.8.5.inc.php | 2 +- main/install/update-files-1.8.5-1.8.6.inc.php | 2 +- main/install/update-files-1.8.6-1.8.6.1.inc.php | 2 +- main/install/update-files-1.8.6.1-1.8.6.2.inc.php | 2 +- main/install/update-files-1.8.6.2-1.8.7.inc.php | 2 +- main/install/update_db.inc.php | 8 ++++---- main/install/update_files.inc.php | 10 +++++----- main/install/upgrade.php | 2 +- 22 files changed, 60 insertions(+), 60 deletions(-) diff --git a/main/install/index.php b/main/install/index.php index 1fbaa09b11..6bff9cd7b9 100755 --- a/main/install/index.php +++ b/main/install/index.php @@ -90,7 +90,7 @@ require_once 'install_upgrade.lib.php'; //also defines constants require_once 'install_functions.inc.php'; // Some constants -define('DOKEOS_INSTALL', 1); +define('SYSTEM_INSTALLATION', 1); define('MAX_COURSE_TRANSFER', 100); define('INSTALL_TYPE_UPDATE', 'update'); define('FORM_FIELD_DISPLAY_LENGTH', 40); diff --git a/main/install/install_db.inc.php b/main/install/install_db.inc.php index a8f63d2ab7..9078c6eb2a 100755 --- a/main/install/install_db.inc.php +++ b/main/install/install_db.inc.php @@ -19,7 +19,7 @@ require_once 'install_upgrade.lib.php'; // This page can only be access through including from the install script. -if (!defined('DOKEOS_INSTALL')) { +if (!defined('SYSTEM_INSTALLATION')) { echo 'You are not allowed here!'; exit; } diff --git a/main/install/install_files.inc.php b/main/install/install_files.inc.php index 6b6f8ad81c..09e6880941 100755 --- a/main/install/install_files.inc.php +++ b/main/install/install_files.inc.php @@ -15,7 +15,7 @@ ============================================================================== */ -if (defined('DOKEOS_INSTALL')) { +if (defined('SYSTEM_INSTALLATION')) { // Write the system config file write_dokeos_config_file('../inc/conf/configuration.php'); diff --git a/main/install/update-db-1.6.x-1.8.0.inc.php b/main/install/update-db-1.6.x-1.8.0.inc.php index 8ed95834eb..89eebdc494 100755 --- a/main/install/update-db-1.6.x-1.8.0.inc.php +++ b/main/install/update-db-1.6.x-1.8.0.inc.php @@ -54,7 +54,7 @@ if (function_exists('ini_set')) { */ //check if we come from index.php or update_courses.php - otherwise display error msg -if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) { +if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) { //check if the current Dokeos install is elligible for update if (empty ($updateFromConfigFile) || !file_exists($_POST['updatePath'].$updateFromConfigFile) || !in_array(get_config_param('clarolineVersion'), $update_from_version_6)) { @@ -98,8 +98,8 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) { '.get_lang('DBHost').' : '.$dbHostForm.'
'.get_lang('DBLogin').' : '.$dbUsernameForm.'
'.get_lang('DBPassword').' : '.$dbPassForm.'

- '.get_lang('PleaseGoBackToStep').' '. (defined('DOKEOS_INSTALL') ? '3' : '1').'. -

+ '.get_lang('PleaseGoBackToStep').' '. (defined('SYSTEM_INSTALLATION') ? '3' : '1').'. +

'; exit (); @@ -123,7 +123,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) { $only_test = false; $log = 0; - if (defined('DOKEOS_INSTALL')) { + if (defined('SYSTEM_INSTALLATION')) { if ($singleDbForm) { if (empty($dbStatsForm)) $dbStatsForm = $dbNameForm; @@ -445,7 +445,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) { if (!$only_test){ include('update-db-scorm-1.6.x-1.8.0.inc.php'); } - if (defined('DOKEOS_INSTALL')) { + if (defined('SYSTEM_INSTALLATION')) { if ($singleDbForm) { if(empty($dbStatsForm)) $dbStatsForm = $dbNameForm; if(empty($dbScormForm)) $dbScormForm = $dbNameForm; diff --git a/main/install/update-db-1.8.0-1.8.2.inc.php b/main/install/update-db-1.8.0-1.8.2.inc.php index c29316628f..26ed4d891b 100755 --- a/main/install/update-db-1.8.0-1.8.2.inc.php +++ b/main/install/update-db-1.8.0-1.8.2.inc.php @@ -54,7 +54,7 @@ if (function_exists('ini_set')) { */ //check if we come from index.php or update_courses.php - otherwise display error msg -if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) { +if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) { //check if the current Dokeos install is elligible for update if (!file_exists('../inc/conf/configuration.php')) { @@ -97,8 +97,8 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) { '.get_lang('DBHost').' : '.$dbHostForm.'
'.get_lang('DBLogin').' : '.$dbUsernameForm.'
'.get_lang('DBPassword').' : '.$dbPassForm.'

- '.get_lang('PleaseGoBackToStep').' '. (defined('DOKEOS_INSTALL') ? '3' : '1').'. -

+ '.get_lang('PleaseGoBackToStep').' '. (defined('SYSTEM_INSTALLATION') ? '3' : '1').'. +

'; exit (); @@ -121,7 +121,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) { // that we want to change the main databases as well... $only_test = false; $log = 0; - if (defined('DOKEOS_INSTALL')) { + if (defined('SYSTEM_INSTALLATION')) { if ($singleDbForm) { $dbStatsForm = $dbNameForm; $dbScormForm = $dbNameForm; diff --git a/main/install/update-db-1.8.2-1.8.3.inc.php b/main/install/update-db-1.8.2-1.8.3.inc.php index 5e51bf6790..f578267ace 100755 --- a/main/install/update-db-1.8.2-1.8.3.inc.php +++ b/main/install/update-db-1.8.2-1.8.3.inc.php @@ -54,7 +54,7 @@ if( function_exists('ini_set')) { */ //check if we come from index.php or update_courses.php - otherwise display error msg -if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) { +if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) { //check if the current Dokeos install is elligible for update if (!file_exists('../inc/conf/configuration.php')) { @@ -97,8 +97,8 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) { '.get_lang('DBHost').' : '.$dbHostForm.'
'.get_lang('DBLogin').' : '.$dbUsernameForm.'
'.get_lang('DBPassword').' : '.$dbPassForm.'

- '.get_lang('PleaseGoBackToStep').' '. (defined('DOKEOS_INSTALL') ? '3' : '1').'. -

+ '.get_lang('PleaseGoBackToStep').' '. (defined('SYSTEM_INSTALLATION') ? '3' : '1').'. +

'; exit (); } @@ -120,7 +120,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) { // that we want to change the main databases as well... $only_test = false; $log = 0; - if (defined('DOKEOS_INSTALL')) { + if (defined('SYSTEM_INSTALLATION')) { if ($singleDbForm) { $dbStatsForm = $dbNameForm; diff --git a/main/install/update-db-1.8.3-1.8.4.inc.php b/main/install/update-db-1.8.3-1.8.4.inc.php index 0c17f9a37b..6b994a8db5 100755 --- a/main/install/update-db-1.8.3-1.8.4.inc.php +++ b/main/install/update-db-1.8.3-1.8.4.inc.php @@ -54,7 +54,7 @@ if (function_exists('ini_set')) { */ //check if we come from index.php or update_courses.php - otherwise display error msg -if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) { +if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) { //check if the current Dokeos install is elligible for update if (!file_exists('../inc/conf/configuration.php')) { echo ''.get_lang('Error').' ! Dokeos '.implode('|', $updateFromVersion).' '.get_lang('HasNotBeenFound').'.

@@ -96,8 +96,8 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) { '.get_lang('DBHost').' : '.$dbHostForm.'
'.get_lang('DBLogin').' : '.$dbUsernameForm.'
'.get_lang('DBPassword').' : '.$dbPassForm.'

- '.get_lang('PleaseGoBackToStep').' '. (defined('DOKEOS_INSTALL') ? '3' : '1').'. -

+ '.get_lang('PleaseGoBackToStep').' '. (defined('SYSTEM_INSTALLATION') ? '3' : '1').'. +

'; exit (); } @@ -119,7 +119,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) { // that we want to change the main databases as well... $only_test = false; $log = 0; - if (defined('DOKEOS_INSTALL')) { + if (defined('SYSTEM_INSTALLATION')) { if ($singleDbForm) { $dbStatsForm = $dbNameForm; diff --git a/main/install/update-db-1.8.4-1.8.5.inc.php b/main/install/update-db-1.8.4-1.8.5.inc.php index 9992477f2b..141a47a665 100755 --- a/main/install/update-db-1.8.4-1.8.5.inc.php +++ b/main/install/update-db-1.8.4-1.8.5.inc.php @@ -36,7 +36,7 @@ if (function_exists('ini_set')) { */ //check if we come from index.php or update_courses.php - otherwise display error msg -if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) { +if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) { //check if the current Dokeos install is elligible for update if (!file_exists('../inc/conf/configuration.php')) { echo ''.get_lang('Error').' ! Dokeos '.implode('|', $updateFromVersion).' '.get_lang('HasNotBeenFound').'.

@@ -78,8 +78,8 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) { '.get_lang('DBHost').' : '.$dbHostForm.'
'.get_lang('DBLogin').' : '.$dbUsernameForm.'
'.get_lang('DBPassword').' : '.$dbPassForm.'

- '.get_lang('PleaseGoBackToStep').' '. (defined('DOKEOS_INSTALL') ? '3' : '1').'. -

+ '.get_lang('PleaseGoBackToStep').' '. (defined('SYSTEM_INSTALLATION') ? '3' : '1').'. +

'; exit (); } @@ -101,7 +101,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) { // that we want to change the main databases as well... $only_test = false; $log = 0; - if (defined('DOKEOS_INSTALL')) { + if (defined('SYSTEM_INSTALLATION')) { if ($singleDbForm) { $dbStatsForm = $dbNameForm; diff --git a/main/install/update-db-1.8.5-1.8.6.inc.php b/main/install/update-db-1.8.5-1.8.6.inc.php index 50f51774eb..c212e10cc8 100755 --- a/main/install/update-db-1.8.5-1.8.6.inc.php +++ b/main/install/update-db-1.8.5-1.8.6.inc.php @@ -36,7 +36,7 @@ if (function_exists('ini_set')) { */ //check if we come from index.php or update_courses.php - otherwise display error msg -if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) { +if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) { //check if the current Dokeos install is elligible for update if (!file_exists('../inc/conf/configuration.php')) { @@ -79,8 +79,8 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) { '.get_lang('DBHost').' : '.$dbHostForm.'
'.get_lang('DBLogin').' : '.$dbUsernameForm.'
'.get_lang('DBPassword').' : '.$dbPassForm.'

- '.get_lang('PleaseGoBackToStep').' '. (defined('DOKEOS_INSTALL') ? '3' : '1').'. -

+ '.get_lang('PleaseGoBackToStep').' '. (defined('SYSTEM_INSTALLATION') ? '3' : '1').'. +

'; exit (); } @@ -105,7 +105,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) { // that we want to change the main databases as well... $only_test = false; $log = 0; - if (defined('DOKEOS_INSTALL')) { + if (defined('SYSTEM_INSTALLATION')) { if ($singleDbForm) { $dbStatsForm = $dbNameForm; diff --git a/main/install/update-db-1.8.6-1.8.6.1.inc.php b/main/install/update-db-1.8.6-1.8.6.1.inc.php index 548142062b..1f5e86a46a 100755 --- a/main/install/update-db-1.8.6-1.8.6.1.inc.php +++ b/main/install/update-db-1.8.6-1.8.6.1.inc.php @@ -36,7 +36,7 @@ if (function_exists('ini_set')) { */ //check if we come from index.php or update_courses.php - otherwise display error msg -if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) { +if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) { //check if the current Dokeos install is elligible for update if (!file_exists('../inc/conf/configuration.php')) { @@ -79,8 +79,8 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) { '.get_lang('DBHost').' : '.$dbHostForm.'
'.get_lang('DBLogin').' : '.$dbUsernameForm.'
'.get_lang('DBPassword').' : '.$dbPassForm.'

- '.get_lang('PleaseGoBackToStep').' '. (defined('DOKEOS_INSTALL') ? '3' : '1').'. -

+ '.get_lang('PleaseGoBackToStep').' '. (defined('SYSTEM_INSTALLATION') ? '3' : '1').'. +

'; exit (); } @@ -102,7 +102,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) { // that we want to change the main databases as well... $only_test = false; $log = 0; - if (defined('DOKEOS_INSTALL')) { + if (defined('SYSTEM_INSTALLATION')) { if ($singleDbForm) { $dbStatsForm = $dbNameForm; diff --git a/main/install/update-db-1.8.6.1-1.8.6.2.inc.php b/main/install/update-db-1.8.6.1-1.8.6.2.inc.php index b5053d62ca..8e9b82fe45 100755 --- a/main/install/update-db-1.8.6.1-1.8.6.2.inc.php +++ b/main/install/update-db-1.8.6.1-1.8.6.2.inc.php @@ -36,7 +36,7 @@ if (function_exists('ini_set')) { */ //check if we come from index.php or update_courses.php - otherwise display error msg -if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) { +if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) { //check if the current Dokeos install is elligible for update if (!file_exists('../inc/conf/configuration.php')) { @@ -79,8 +79,8 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) { '.get_lang('DBHost').' : '.$dbHostForm.'
'.get_lang('DBLogin').' : '.$dbUsernameForm.'
'.get_lang('DBPassword').' : '.$dbPassForm.'

- '.get_lang('PleaseGoBackToStep').' '. (defined('DOKEOS_INSTALL') ? '3' : '1').'. -

+ '.get_lang('PleaseGoBackToStep').' '. (defined('SYSTEM_INSTALLATION') ? '3' : '1').'. +

'; exit (); } @@ -102,7 +102,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) { // that we want to change the main databases as well... $only_test = false; $log = 0; - if (defined('DOKEOS_INSTALL')) { + if (defined('SYSTEM_INSTALLATION')) { if ($singleDbForm) { $dbStatsForm = $dbNameForm; diff --git a/main/install/update-db-1.8.6.2-1.8.7.inc.php b/main/install/update-db-1.8.6.2-1.8.7.inc.php index 9cad62b89d..25d820a1fd 100755 --- a/main/install/update-db-1.8.6.2-1.8.7.inc.php +++ b/main/install/update-db-1.8.6.2-1.8.7.inc.php @@ -36,7 +36,7 @@ if (function_exists('ini_set')) { */ //check if we come from index.php or update_courses.php - otherwise display error msg -if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) { +if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) { //check if the current Dokeos install is elligible for update if (!file_exists('../inc/conf/configuration.php')) { @@ -79,8 +79,8 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) { '.get_lang('DBHost').' : '.$dbHostForm.'
'.get_lang('DBLogin').' : '.$dbUsernameForm.'
'.get_lang('DBPassword').' : '.$dbPassForm.'

- '.get_lang('PleaseGoBackToStep').' '. (defined('DOKEOS_INSTALL') ? '3' : '1').'. -

+ '.get_lang('PleaseGoBackToStep').' '. (defined('SYSTEM_INSTALLATION') ? '3' : '1').'. +

'; exit (); } @@ -102,7 +102,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) { // that we want to change the main databases as well... $only_test = false; $log = 0; - if (defined('DOKEOS_INSTALL')) { + if (defined('SYSTEM_INSTALLATION')) { if ($singleDbForm) { $dbStatsForm = $dbNameForm; diff --git a/main/install/update-files-1.6.x-1.8.0.inc.php b/main/install/update-files-1.6.x-1.8.0.inc.php index ccb50c8487..1c66666b32 100755 --- a/main/install/update-files-1.6.x-1.8.0.inc.php +++ b/main/install/update-files-1.6.x-1.8.0.inc.php @@ -27,13 +27,13 @@ * IMPORTANT: This script has to be included by install/index.php or * update_courses.php * -* DOKEOS_INSTALL is defined in the install/index.php (means that we are in +* SYSTEM_INSTALLATION is defined in the install/index.php (means that we are in * the regular upgrade process) * * DOKEOS_COURSE_UPDATE is defined in update_courses.php (means we are * executing update_courses.php to update courses separately) * -* When DOKEOS_INSTALL or DOKEOS_COURSE_UPDATE are defined, do for every course: +* When SYSTEM_INSTALLATION or DOKEOS_COURSE_UPDATE are defined, do for every course: * - create a new set of directories that reflect the new tools offered by 1.8 * - record an item_property for each directory added * @@ -67,7 +67,7 @@ function insert_db($db_name, $folder_name, $text) { ============================================================================== */ -if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) { +if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) { $sys_course_path = $pathForm.'courses/'; //$tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE); @@ -192,7 +192,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) { rename($updatePath.'claroline/upload/video', $pathForm.'main/upload/video'); /* - if (defined('DOKEOS_INSTALL')) { + if (defined('SYSTEM_INSTALLATION')) { //nothing to do this time } */ diff --git a/main/install/update-files-1.8.3-1.8.4.inc.php b/main/install/update-files-1.8.3-1.8.4.inc.php index 12f2a327bf..263a6923b5 100755 --- a/main/install/update-files-1.8.3-1.8.4.inc.php +++ b/main/install/update-files-1.8.3-1.8.4.inc.php @@ -40,7 +40,7 @@ require_once '../inc/lib/main_api.lib.php'; require_once '../inc/lib/fileUpload.lib.php'; require_once '../inc/lib/database.lib.php'; -if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) { +if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) { // Edit the Dokeos config file $file = file('../inc/conf/configuration.php'); diff --git a/main/install/update-files-1.8.4-1.8.5.inc.php b/main/install/update-files-1.8.4-1.8.5.inc.php index f033ec2fa0..cd9a501c71 100755 --- a/main/install/update-files-1.8.4-1.8.5.inc.php +++ b/main/install/update-files-1.8.4-1.8.5.inc.php @@ -19,7 +19,7 @@ require_once '../inc/lib/main_api.lib.php'; require_once '../inc/lib/fileUpload.lib.php'; require_once '../inc/lib/database.lib.php'; -if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) { +if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) { // Edit the Dokeos config file $file = file('../inc/conf/configuration.php'); diff --git a/main/install/update-files-1.8.5-1.8.6.inc.php b/main/install/update-files-1.8.5-1.8.6.inc.php index 5c3a12e9c4..609c2dfb49 100755 --- a/main/install/update-files-1.8.5-1.8.6.inc.php +++ b/main/install/update-files-1.8.5-1.8.6.inc.php @@ -19,7 +19,7 @@ require_once '../inc/lib/main_api.lib.php'; require_once '../inc/lib/fileUpload.lib.php'; require_once '../inc/lib/database.lib.php'; -if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) { +if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) { // Edit the Dokeos config file $file = file('../inc/conf/configuration.php'); diff --git a/main/install/update-files-1.8.6-1.8.6.1.inc.php b/main/install/update-files-1.8.6-1.8.6.1.inc.php index dad28f872f..b5c55de449 100755 --- a/main/install/update-files-1.8.6-1.8.6.1.inc.php +++ b/main/install/update-files-1.8.6-1.8.6.1.inc.php @@ -19,7 +19,7 @@ require_once '../inc/lib/main_api.lib.php'; require_once '../inc/lib/fileUpload.lib.php'; require_once '../inc/lib/database.lib.php'; -if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) { +if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) { // Edit the Dokeos config file $file = file('../inc/conf/configuration.php'); diff --git a/main/install/update-files-1.8.6.1-1.8.6.2.inc.php b/main/install/update-files-1.8.6.1-1.8.6.2.inc.php index c9beffed59..e6e34a86dd 100755 --- a/main/install/update-files-1.8.6.1-1.8.6.2.inc.php +++ b/main/install/update-files-1.8.6.1-1.8.6.2.inc.php @@ -13,7 +13,7 @@ require_once '../inc/lib/main_api.lib.php'; require_once '../inc/lib/fileUpload.lib.php'; require_once '../inc/lib/database.lib.php'; -if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) { +if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) { // Edit the Dokeos config file $file = file('../inc/conf/configuration.php'); $fh = fopen('../inc/conf/configuration.php', 'w'); diff --git a/main/install/update-files-1.8.6.2-1.8.7.inc.php b/main/install/update-files-1.8.6.2-1.8.7.inc.php index a296f7171a..1c2645f66b 100755 --- a/main/install/update-files-1.8.6.2-1.8.7.inc.php +++ b/main/install/update-files-1.8.6.2-1.8.7.inc.php @@ -13,7 +13,7 @@ require_once '../inc/lib/main_api.lib.php'; require_once '../inc/lib/fileUpload.lib.php'; require_once '../inc/lib/database.lib.php'; -if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) { +if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) { // Start coding here... diff --git a/main/install/update_db.inc.php b/main/install/update_db.inc.php index 13e05a564c..f26c0bc717 100755 --- a/main/install/update_db.inc.php +++ b/main/install/update_db.inc.php @@ -48,7 +48,7 @@ require_once("install_upgrade.lib.php"); */ //check if we come from index.php or update_courses.php - otherwise display error msg -if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) +if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) { //check if the current Dokeos install is elligible for update if (empty ($updateFromConfigFile) || !file_exists($_POST['updatePath'].$updateFromConfigFile) || !in_array(get_config_param('clarolineVersion'), $update_from_version)) @@ -95,8 +95,8 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) '.get_lang('DBHost').' : '.$dbHostForm.'
'.get_lang('DBLogin').' : '.$dbUsernameForm.'
'.get_lang('DBPassword').' : '.$dbPassForm.'

- '.get_lang('PleaseGoBackToStep').' '. (defined('DOKEOS_INSTALL') ? '3' : '1').'. -

'.get_lang('Back').'

+ '.get_lang('PleaseGoBackToStep').' '. (defined('SYSTEM_INSTALLATION') ? '3' : '1').'. +

'.get_lang('Back').'

'; exit (); @@ -113,7 +113,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) //if this script has been included by index.php, not update_courses.php, so // that we want to change the main databases as well... $only_test = false; - if (defined('DOKEOS_INSTALL')) + if (defined('SYSTEM_INSTALLATION')) { /** * Update the databases "pre" migration diff --git a/main/install/update_files.inc.php b/main/install/update_files.inc.php index 9fb104fba1..96ca32b7a5 100755 --- a/main/install/update_files.inc.php +++ b/main/install/update_files.inc.php @@ -29,10 +29,10 @@ * Updates the Dokeos files from an older version * IMPORTANT: This script has to be included by install/index.php and update_courses.php * -* DOKEOS_INSTALL is defined in the install/index.php +* SYSTEM_INSTALLATION is defined in the install/index.php * DOKEOS_COURSE_UPDATE is defined in update_courses.php * -* When DOKEOS_INSTALL or DOKEOS_COURSE_UPDATE is defined, do for every course: +* When SYSTEM_INSTALLATION or DOKEOS_COURSE_UPDATE is defined, do for every course: * - remove the .htaccess in the document folder * - remove the index.php in the group folder * - write a new group/index.php file, make it an empty html file @@ -46,7 +46,7 @@ * - remove the visibility field from the document table * - update the item properties of the group documents * -* Additionally, when DOKEOS_INSTALL is defined +* Additionally, when SYSTEM_INSTALLATION is defined * - write a config file, configuration.php, with important settings * - write a .htaccess file (with instructions for Apache) in the courses directory * - remove the new main/upload/users directory and rename the main/img/users @@ -138,7 +138,7 @@ function fill_document_table($dir) ============================================================================== */ -if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) { +if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) { $newPath = str_replace('\\', '/', realpath('../..')).'/'; $oldPath = $_POST['updatePath']; @@ -199,7 +199,7 @@ if (defined('DOKEOS_INSTALL') || defined('DOKEOS_COURSE_UPDATE')) { } } - if (defined('DOKEOS_INSTALL')) { + if (defined('SYSTEM_INSTALLATION')) { // Write the Dokeos config file write_dokeos_config_file($newPath.'main/inc/conf/configuration.php'); diff --git a/main/install/upgrade.php b/main/install/upgrade.php index acca2aef33..f67a645cec 100755 --- a/main/install/upgrade.php +++ b/main/install/upgrade.php @@ -62,7 +62,7 @@ require '../lang/english/install.inc.php'; require_once 'install_upgrade.lib.php'; require_once 'upgrade_lib.php'; -define('DOKEOS_INSTALL', 1); +define('SYSTEM_INSTALLATION', 1); define('MAX_COURSE_TRANSFER', 100); define('INSTALL_TYPE_UPDATE', 'update'); define('FORM_FIELD_DISPLAY_LENGTH', 40); From b78abc370f3a63c55c2df72bf5fe5be3bf005d7f Mon Sep 17 00:00:00 2001 From: Ivan Tcholakov Date: Sun, 14 Feb 2010 19:20:58 +0200 Subject: [PATCH 08/12] Feature #272 - Installation scripts: Renaming some lexems in the code (mostly). --- main/install/index.php | 6 +++--- main/install/install_files.inc.php | 4 ++-- main/install/install_upgrade.lib.php | 18 +++++++----------- main/install/update-files-1.6.x-1.8.0.inc.php | 4 ++-- main/install/update_files.inc.php | 4 ++-- 5 files changed, 16 insertions(+), 20 deletions(-) diff --git a/main/install/index.php b/main/install/index.php index 6bff9cd7b9..a18359803d 100755 --- a/main/install/index.php +++ b/main/install/index.php @@ -246,7 +246,7 @@ if (!isset($_GET['running'])) { } else { foreach ($_POST as $key => $val) { - $magic_quotes_gpc = ini_get('magic_quotes_gpc') ? true : false; + $magic_quotes_gpc = ini_get('magic_quotes_gpc'); if (is_string($val)) { if ($magic_quotes_gpc) { $val = stripslashes($val); @@ -589,7 +589,7 @@ if ($_POST['step2']) { ?>
- + '.$loginForm; ?>
'.$passForm; /* TODO: Maybe this password should be hidden too? */ ?>

@@ -606,7 +606,7 @@ if ($_POST['step2']) {

- !
+ !

diff --git a/main/install/install_files.inc.php b/main/install/install_files.inc.php index 09e6880941..b55abd411a 100755 --- a/main/install/install_files.inc.php +++ b/main/install/install_files.inc.php @@ -18,10 +18,10 @@ if (defined('SYSTEM_INSTALLATION')) { // Write the system config file - write_dokeos_config_file('../inc/conf/configuration.php'); + write_system_config_file('../inc/conf/configuration.php'); // Write a distribution file with the config as a backup for the admin - write_dokeos_config_file('../inc/conf/configuration.dist.php'); + write_system_config_file('../inc/conf/configuration.dist.php'); // Write a .htaccess file in the course repository write_courses_htaccess_file($urlAppendPath); diff --git a/main/install/install_upgrade.lib.php b/main/install/install_upgrade.lib.php index dc6325fd6f..384465c48d 100755 --- a/main/install/install_upgrade.lib.php +++ b/main/install/install_upgrade.lib.php @@ -19,10 +19,10 @@ CONSTANTS ============================================================================== */ -define("DOKEOS_MAIN_DATABASE_FILE", "dokeos_main.sql"); +define("SYSTEM_MAIN_DATABASE_FILE", "dokeos_main.sql"); define("COUNTRY_DATA_FILENAME", "country_data.csv"); define("COURSES_HTACCESS_FILENAME", "htaccess.dist"); -define("DOKEOS_CONFIG_FILENAME", "configuration.dist.php"); +define("SYSTEM_CONFIG_FILENAME", "configuration.dist.php"); require_once api_get_path(LIBRARY_PATH).'database.lib.php'; @@ -70,7 +70,7 @@ function write_courses_htaccess_file($url_append) { * Write the main system config file * @param string $path Path to the config file */ -function write_dokeos_config_file($path) { +function write_system_config_file($path) { global $dbHostForm; global $dbUsernameForm; @@ -93,13 +93,9 @@ function write_dokeos_config_file($path) { global $new_version; global $new_version_stable; - // TODO: api_get_path() to be tested here. - $seek = array('\\', '//'); - $destroy = array('/', '/'); - $rootSys = str_replace($seek, $destroy, realpath($pathForm).'/'); - $file_path = dirname(__FILE__).'/'.DOKEOS_CONFIG_FILENAME; + $root_sys = api_add_trailing_slash(str_replace('\\', '/', realpath($pathForm))); + $content = file_get_contents(dirname(__FILE__).'/'.SYSTEM_CONFIG_FILENAME); - $content = file_get_contents($file_path); $config['{DATE_GENERATED}'] = date('r'); $config['{DATABASE_HOST}'] = $dbHostForm; $config['{DATABASE_USER}'] = $dbUsernameForm; @@ -114,7 +110,7 @@ function write_dokeos_config_file($path) { $config['{DATABASE_SCORM}'] = (($singleDbForm && empty($dbScormForm)) ? $dbNameForm : $dbScormForm); $config['{DATABASE_PERSONAL}'] =(($singleDbForm && empty($dbUserForm)) ? $dbNameForm : $dbUserForm); $config['{ROOT_WEB}'] = $urlForm; - $config['{ROOT_SYS}'] = $rootSys; + $config['{ROOT_SYS}'] = $root_sys; $config['{URL_APPEND_PATH}'] = $urlAppendPath; $config['{PLATFORM_LANGUAGE}'] = $languageForm; $config['{SECURITY_KEY}'] = md5(uniqid(rand().time())); @@ -164,7 +160,7 @@ function load_main_database($installation_settings, $db_script = '') { if (!empty($db_script)) { $dokeos_main_sql_file_string = file_get_contents($db_script); } else { - $dokeos_main_sql_file_string = file_get_contents(DOKEOS_MAIN_DATABASE_FILE); + $dokeos_main_sql_file_string = file_get_contents(SYSTEM_MAIN_DATABASE_FILE); } //replace symbolic parameters with user-specified values diff --git a/main/install/update-files-1.6.x-1.8.0.inc.php b/main/install/update-files-1.6.x-1.8.0.inc.php index 1c66666b32..9f9cf44bc1 100755 --- a/main/install/update-files-1.6.x-1.8.0.inc.php +++ b/main/install/update-files-1.6.x-1.8.0.inc.php @@ -170,9 +170,9 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) { //umask($old_umask); // This function is not thread-safe. // Write the Dokeos config file - write_dokeos_config_file('../inc/conf/configuration.php'); + write_system_config_file('../inc/conf/configuration.php'); // Write a distribution file with the config as a backup for the admin - write_dokeos_config_file('../inc/conf/configuration.dist.php'); + write_system_config_file('../inc/conf/configuration.dist.php'); // Write a .htaccess file in the course repository write_courses_htaccess_file($urlAppendPath); copy($updatePath.'claroline/inc/conf/add_course.conf.php', $pathForm.'main/inc/conf/add_course.conf.php'); diff --git a/main/install/update_files.inc.php b/main/install/update_files.inc.php index 96ca32b7a5..a4becdf3f6 100755 --- a/main/install/update_files.inc.php +++ b/main/install/update_files.inc.php @@ -202,10 +202,10 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) { if (defined('SYSTEM_INSTALLATION')) { // Write the Dokeos config file - write_dokeos_config_file($newPath.'main/inc/conf/configuration.php'); + write_system_config_file($newPath.'main/inc/conf/configuration.php'); // Write a distribution file with the config as a backup for the admin - write_dokeos_config_file($newPath.'main/inc/conf/configuration.dist.php'); + write_system_config_file($newPath.'main/inc/conf/configuration.dist.php'); // Write a .htaccess file in the course repository write_courses_htaccess_file($urlAppendPath); From e3e823d8f63d1d9c3caf212d4f08e65c17f4ed6b Mon Sep 17 00:00:00 2001 From: Ivan Tcholakov Date: Mon, 15 Feb 2010 01:11:44 +0200 Subject: [PATCH 09/12] Feature #272 - Installation scripts: The code for the)language selection box has been reworked. It is about language during installation procedure. Some other minor reworks. --- main/install/install_functions.inc.php | 89 +++++++++----------------- main/install/install_upgrade.lib.php | 83 +++++++++++++++--------- main/install/upgrade.php | 23 ------- 3 files changed, 83 insertions(+), 112 deletions(-) diff --git a/main/install/install_functions.inc.php b/main/install/install_functions.inc.php index ea8d344e5b..bf2b640e74 100755 --- a/main/install/install_functions.inc.php +++ b/main/install/install_functions.inc.php @@ -231,50 +231,17 @@ function get_config_param($param, $updatePath = '') { */ function get_config_param_from_db($host, $login, $pass, $db_name, $param = '') { - $mydb = mysql_connect($host, $login, $pass); - @mysql_query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5) - - $myconnect = mysql_select_db($db_name); - - $sql = "SELECT * FROM settings_current WHERE variable = '$param'"; - $res = mysql_query($sql); - if ($res === false) { - return null; - } - - if (mysql_num_rows($res) > 0) { - $row = mysql_fetch_array($res); - $value = $row['selected_value']; - return $value; - } - return null; -} - -/** - * TODO: The main API is accessible here. Then we could use a function for this purpose from there? - * - * Return a list of language directories. - * @todo function does not belong here, move to code library, - * also see infocours.php which contains similar function - */ -function get_language_folder_list($dirname) { - if ($dirname[strlen($dirname) - 1] != '/') { - $dirname .= '/'; - } - $handle = opendir($dirname); - $language_list = array(); - - while ($entries = readdir($handle)) { - if ($entries == '.' || $entries == '..' || $entries=='CVS' || $entries == '.svn') { - continue; - } - if (is_dir($dirname.$entries)) { - $language_list[] = $entries; + Database::connect(array('server' => $host, 'username' => $login, 'password' => $pass)); + Database::query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5) + Database::select_db($db_name); + + if (($res = Database::query("SELECT * FROM settings_current WHERE variable = '$param'")) !== false) { + if (Database::num_rows($res) > 0) { + $row = Database::fetch_array($res); + return $row['selected_value']; } } - - closedir($handle); - return $language_list; + return null; } /* @@ -284,34 +251,38 @@ function get_language_folder_list($dirname) { */ /** - * Displays a form (drop down menu) so the user can select - * his/her preferred language. + * Displays a drop down box for selection the preferred language. */ function display_language_selection_box() { - //get language list - $language_list = get_language_folder_list(api_get_path(SYS_LANG_PATH)); - sort($language_list); - //Reduce the number of languages shown to only show those with higher than 90% translation in DLTT - //This option can be easily removed later on. The aim is to test people response to less choice - //$language_to_display = $language_list; - $language_to_display = array('asturian', 'bulgarian', 'english', 'italian', 'french', 'slovenian', 'slovenian_unicode', 'spanish'); + // Reading language list. + $language_list = get_language_folder_list(); - //display - echo "\t\t\n"; + foreach ($language_list as $key => $value) { + if ($key == $default_language) { $option_end = ' selected="selected">'; } else { $option_end = '>'; } - echo "\t\t\t