diff --git a/main/install/_INSTALL.txt b/main/install/_INSTALL.txt deleted file mode 100644 index 4ef984d27d..0000000000 --- a/main/install/_INSTALL.txt +++ /dev/null @@ -1,2 +0,0 @@ -For installation help, see installation_guide.html or INSTALL.txt at the Chamilo root directory -(which should be two directories up from this) \ No newline at end of file diff --git a/main/install/_compare_db.php b/main/install/_compare_db.php deleted file mode 100644 index 745fec1341..0000000000 --- a/main/install/_compare_db.php +++ /dev/null @@ -1,271 +0,0 @@ - 'Field', 1 => 'Type', 2 => 'Null', 3 => 'Key', 4 => 'Default', 5 => 'Extra'); - -/********************************/ - -$all_db_changes = array(); - -echo "

Databases structure comparison script

"; - -// Iterate through databases given above (checking from the 'new' database side) -foreach ($bases_new as $num_base => $base) { - - //init tables lists for this database - $modif_tables = array(); - $tables_db_new = array(); - $tables_db_old = array(); - $dump = array(); - - // Display current processed database - echo "

Now analysing differences between databases $base and ".$bases_old[$num_base]."

"; - - // Get a list of tables for this database - $query_new = "SHOW TABLES FROM ".$bases_new[$num_base]; - $result_new = mysql_query($query_new, $db_new); - - if ($result_new) { //if there are tables in this database - - $i=0; - - //as there are tables, process them one by one - while ($row_new = mysql_fetch_row($result_new)) { - - $dump[$i]['table_name'] = $row_new[0]; - $dump[$i]['fields'] = array(); - - $query_old = "SHOW FIELDS FROM ".$bases_new[$num_base].".".$row_new[0]; - $result_old = mysql_query($query_old,$db_old) or die(mysql_error()); - - $j=0; - - //get the fields details (numbered fields) - while ($row_old = mysql_fetch_row($result_old)) { - - $dump[$i]['fields'][$j][0] = $row_old[0]; - $dump[$i]['fields'][$j][1] = $row_old[1]; - $dump[$i]['fields'][$j][2] = $row_old[2]; - $dump[$i]['fields'][$j][3] = $row_old[3]; - $dump[$i]['fields'][$j][4] = $row_old[4]; - $dump[$i]['fields'][$j][5] = $row_old[5]; - //get the field name in one special element of this array - $dump[$i]['field_names'][$row_old[0]] = $j; - - $j++; - } - - $i++; - } - - foreach ($dump as $table) { - - $query = "SHOW FIELDS FROM ".$bases_old[$num_base].".".$table['table_name']; - $result = mysql_query($query,$db_old); - - if (!$result) { - - $modif_tables[]='**'.$table['table_name'].'**'; - - } else { - - $i = 0; - - //check for removed, new or modified fields - $fields_old = array(); - $fields_new = array(); - - //list the new fields in a enumeration array - foreach ($table['field_names'] as $dummy_key => $dummy_field) { - $fields_new[] = $dummy_key; - } - - //list the old fields in an enumeration array and check if their corresponding field in the new table is different (if any) - $modif_fields = array(); - while ($row_old = mysql_fetch_row($result)) { - - $fields_old[] = $row_old[0]; - $modif_field = ''; - - if (isset($table['fields'][$table['field_names'][$row_old[0]]])) { - $field_info = $table['fields'][$table['field_names'][$row_old[0]]]; - foreach ($row_old as $key => $enreg) { - //if the old field information of this kind doesn't match the new, record it - if ($row_old[$key] != $field_info[$key]) { - $modif_field .= '~+~'.$field_details[$key].'~+~,'; - break; - } - } - //only record the whole stuff if the string is not empty - if (strlen($modif_field) > 0) { - $modif_fields[$row_old[0]] .= substr($modif_field, 0, -1); - } - } - } - - $new_fields = array_diff($fields_new, $fields_old); - foreach ($new_fields as $dummy => $val) { - $new_fields[$dummy] = '++'.$val.'++'; - } - - $old_fields = array_diff($fields_old, $fields_new); - foreach ($old_fields as $dummy => $val) { - $old_fields[$dummy] = '--'.$val.'--'; - } - - if (count($old_fields) > 0 or count($modif_fields) > 0 or count($new_fields) > 0 ) { - $modif_tables[] = array( - 'table' => $table['table_name'], - 'old_fields' => $old_fields, - 'changed_fields' => $modif_fields, - 'new_fields' => $new_fields, - ); - } - } - $tables_db_new[] = $table['table_name']; - } - - $query = "SHOW TABLES FROM ".$bases_old[$num_base]; - $result = mysql_query($query, $db_old) or die(mysql_error()); - - while ($row = mysql_fetch_row($result)) { - $tables_db_old[] = $row[0]; - } - - $diff = array_diff($tables_db_old, $tables_db_new); - - foreach ($diff as $enreg) { - $modif_tables[] = '---'.$enreg.'---'; - } - //$modif_tables = array_unique($modif_tables); //deprecated with the structure complexification - - } else { //this database was removed in the new version - - $query = "SHOW TABLES FROM ".$bases_old[$num_base]; - $result = mysql_query($query, $db_old) or die(mysql_error()); - - while ($row = mysql_fetch_row($result)) { - $tables_db_old[] = $row[0]; - } - - $diff = array_diff($tables_db_old, $tables_db_new); - - foreach ($diff as $enreg) { - $modif_tables[] = '---'.$enreg.'---'; - } - - $modif_tables = array_unique($modif_tables); - echo "

This database has been removed!

"; - } - echo "

Differences between each table

" . - "- fields display under each table's name,
" . - "- new tables are surrounded by '**',
" . - "- removed tables are surrounded by '---',
" . - "- new fields are surrounded by '++',
" . - "- removed fields are surrounded by '--',
" . - "- modified fields are surrounded by '~+~',
"; - echo '
'.print_r($modif_tables, true).'
'; - $all_db_changes[$base] = $modif_tables; -} - -mysql_close($db_new); -mysql_close($db_old); - -echo "

Generating SQL

"; - -//going through all databases changes -foreach ($all_db_changes as $base => $changes) { - echo "

SQL for DB $base

"; - - foreach ($changes as $table) { - - if (is_array($table)) { - //we have a field-level difference - $mytable = $table['table']; - $myold = $table['old_fields']; - $mychanged = $table['changed_fields']; - $mynew = $table['new_fields']; - - foreach ($myold as $myname) { - //column lost, display DROP command - $myname = str_replace('--', '', $myname); - echo "ALTER TABLE ".$mytable." DROP ".$myname."
"; - } - - foreach ($mychanged as $myname => $myprop) { - //field changed, display SET command - $myprops = split(',', $myprop); - $myprops_string = ''; - foreach ($myprops as $myprop) { - $myprop = str_replace('~+~', '', $myprop); - $myprops_string .= $myprop." "; - } - echo "ALTER TABLE ".$mytable." CHANGE $myname $myname $myprops_string
"; - } - - foreach ($mynew as $myname) { - //column created, display ADD command - $myname = str_replace('++', '', $myname); - echo "ALTER TABLE ".$mytable." ADD $myname...
"; - } - - } else { - - //we have a table-level difference - $open_tag = substr($table, 0, 2); - switch ($open_tag) { - case '**': - //new table, display CREATE TABLE command - $table = str_replace('**', '', $table); - echo "CREATE TABLE ".$table."();
"; - break; - case '--': - //dropped table, display DROP TABLE command - $table = str_replace('---', '', $table); - echo "DROP TABLE ".$table."();
"; - break; - default: - echo "Unknown table problem: ".$table."
"; - break; - } - } - } -} diff --git a/main/install/_install_functions.inc.php b/main/install/_install_functions.inc.php deleted file mode 100644 index 59fba59608..0000000000 --- a/main/install/_install_functions.inc.php +++ /dev/null @@ -1,1133 +0,0 @@ -, Ghent University - */ -function step_active($param) { - global $current_step; - if ($param == $current_step) { - echo 'class="current_step" '; - } -} - -/** - * This function displays the Step X of Y - - * @return string String that says 'Step X of Y' with the right values - */ -function display_step_sequence() { - global $current_step; - global $total_steps; - return get_lang('Step'.$current_step).' – '; -} - -/** - * This function checks if a php extension exists or not and returns an HTML - * status string. - * - * @param string Name of the PHP extension to be checked - * @param string Text to show when extension is available (defaults to 'OK') - * @param string Text to show when extension is available (defaults to 'KO') - * @param boolean Whether this extension is optional (in this case show unavailable text in orange rather than red) - * @return string HTML string reporting the status of this extension. Language-aware. - * @author Christophe Gesché - * @author Patrick Cool , Ghent University - * @author Yannick Warnier - * @version Dokeos 1.8.1, May 2007 - */ -function check_extension($extension_name, $return_success = 'Yes', $return_failure = 'No', $optional = false) { - if (extension_loaded($extension_name)) { - return ''.$return_success.''; - } else { - if ($optional) { - return ''.$return_failure.''; - } else { - return ''.$return_failure.''; - } - } -} - -/** - * This function checks whether a php setting matches the recommended value - * - * @author Patrick Cool , Ghent University - * @version Dokeos 1.8, august 2006 - */ -function check_php_setting($php_setting, $recommended_value, $return_success = false, $return_failure = false) { - $current_php_value = get_php_setting($php_setting); - if ($current_php_value == $recommended_value) { - return ''.$current_php_value.' '.$return_success.''; - } else { - return ''.$current_php_value.' '.$return_failure.''; - } -} - -/** - * Returns a textual value ('ON' or 'OFF') based on a requester 2-state ini- configuration setting. - * - * @param string $val a php ini value - * @return boolean: ON or OFF - * @author Joomla - */ -function get_php_setting($val) { - return ini_get($val) == '1' ? 'ON' : 'OFF'; -} - -/** - * This function checks if the given folder is writable - */ -function check_writable($folder, $suggestion = false) { - if (is_writable('../'.$folder)) { - return ''.get_lang('Writable').''; - } else { - if ($suggestion) { - return ''.get_lang('NotWritable').''; - } else { - return ''.get_lang('NotWritable').''; - } - } -} - -/** - * This function returns a string "true" or "false" according to the passed parameter. - * - * @param integer $var The variable to present as text - * @return string the string "true" or "false" - * @author Christophe Gesché - */ -function true_false($var) { - return $var ? 'true' : 'false'; -} - -/** - * This function is similar to the core file() function, except that it - * works with line endings in Windows (which is not the case of file()) - * @param string File path - * @return array The lines of the file returned as an array - */ -function file_to_array($filename) { - $fp = fopen($filename, 'rb'); - $buffer = fread($fp, filesize($filename)); - fclose($fp); - return explode('
', nl2br($buffer)); -} - -/** - * This function returns the value of a parameter from the configuration file - * - * WARNING - this function relies heavily on global variables $updateFromConfigFile - * and $configFile, and also changes these globals. This can be rewritten. - * - * @param string $param the parameter of which the value is returned - * @param string If we want to give the path rather than take it from POST - * @return string the value of the parameter - * @author Olivier Brouckaert - * @author Reworked by Ivan Tcholakov, 2010 - */ -function get_config_param($param, $updatePath = '') { - global $configFile, $updateFromConfigFile; - - // Look if we already have the queried parameter. - if (is_array($configFile) && isset($configFile[$param])) { - return $configFile[$param]; - } - if (empty($updatePath) && !empty($_POST['updatePath'])) { - $updatePath = $_POST['updatePath']; - } - $updatePath = realpath($updatePath).'/'; - $updateFromInstalledVersionFile = ''; - - 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'; - } 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); - return null; - } - } - - if (file_exists($updatePath.'main/inc/installedVersion.inc.php')) { - - $updateFromInstalledVersionFile = $updatePath.'main/inc/installedVersion.inc.php'; - - } elseif (file_exists($updatePath.$updateFromConfigFile)) { - - // The parameter was not found among the global variables, so look into the old configuration file. - - // Make sure the installedVersion file is read first so it is overwritten - // by the config file if the config file contains the version (from 1.8.4). - $config_data_2 = array(); - if (file_exists($updatePath.$updateFromInstalledVersionFile)) { - $config_data_2 = file_to_array($updatePath.$updateFromInstalledVersionFile); - } - $configFile = array(); - $config_data = file_to_array($updatePath.$updateFromConfigFile); - $config_data = array_merge($config_data, $config_data_2); - $val = ''; - - // Parse the configuration file, statement by statement (line by line, actually). - foreach ($config_data as $php_statement) { - - if (strpos($php_statement, '=') !== false) { - // Variable assignment statement have been detected (probably). - // It is expected to be as follows: - // $variable = 'some_value'; // A comment that is not mandatory. - - // Split the statement into its left and right sides. - $php_statement = explode('=', $php_statement); - $variable = trim($php_statement[0]); - $value = $php_statement[1]; - - if (substr($variable, 0, 1) == '$') { - // We have for sure a php variable assignment detected. - - // On the left side: Retrieve the pure variable's name - $variable = trim(str_replace('$', '', $variable)); - - // On the right side: Remove the comment, if it exists. - list($value) = explode(' //', $value); - // Remove extra whitespace, if any. Remove the trailing semicolon (;). - $value = substr(trim($value), 0, -1); - // Remove surroundig quotes, restore escaped quotes. - $value = str_replace('\"', '"', preg_replace('/^"|"$/', '', $value)); - $value = str_replace('\'', '"', preg_replace('/^\'|\'$/', '', $value)); - - if (strtolower($value) == 'true') { - - // A boolean true value have been recognized. - $value = 1; - - } elseif (strtolower($value) == 'false') { - - // A boolean false value have been recognized. - $value = 0; - - } else { - - // Probably we have a string value, but also we have to check - // possible string concatenations that may include string values - // and other configuration variables. I this case we have to - // get the calculated result of the concatenation. - $implode_string = ' '; - if (!strstr($value, '." ".') && strstr($value, '.$')) { - // Yes, there is concatenation, insert a special separator string. - $value = str_replace('.$', '." ".$', $value); - $implode_string = ''; - } - - // Split the concatenated values, if they are more than one. - $sub_strings = explode('." ".', $value); - - // Seek for variables and retrieve their values. - foreach ($sub_strings as $key => & $sub_string) { - if (preg_match('/^\$[a-zA-Z_][a-zA-Z0-9_]*$/', $sub_string)) { - // A variable has been detected, read it by recursive call. - $sub_string = get_config_param(str_replace('$', '', $sub_string)); - } - } - - // Concatenate everything into the final, the calculated string value. - $value = implode($implode_string, $sub_strings); - } - - // Cache the result value. - $configFile[$variable] = $value; - - $a = explode("'", $variable); - $key_tmp = $a[1]; - if ($key_tmp == $param) { - $val = $value; - } - } - } - } - - return $val; - - } else { - error_log('Config array could not be found in get_config_param()', 0); - return null; - } -} - -/** - * Get the config param from the database. If not found, return null - * @param string DB Host - * @param string DB login - * @param string DB pass - * @param string DB name - * @param string Name of param we want - * @return mixed The parameter value or null if not found - */ -function get_config_param_from_db($host, $login, $pass, $db_name, $param = '') { - - 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']; - } - } - return null; -} - -/* -============================================================================== - DISPLAY FUNCTIONS -============================================================================== -*/ - -/** - * Displays a drop down box for selection the preferred language. - */ -function display_language_selection_box($name = 'language_list', $default_language = 'english') { - // Reading language list. - $language_list = get_language_folder_list(); - - /* - // Reduction of the number of languages shown. Enable this fragment of code for customization purposes. - // Modify the language list according to your preference. Don't exclude the 'english' item. - $language_to_display = array('asturian', 'bulgarian', 'english', 'italian', 'french', 'slovenian', 'slovenian_unicode', 'spanish'); - foreach ($language_list as $key => & $value) { - if (!in_array($key, $language_to_display)) { - unset($language_list[$key]); - } - } - */ - - // Sanity checks due to the possibility for customizations. - if (!is_array($language_list) || empty($language_list)) { - $language_list = array('english' => 'English'); - } - - // Sorting again, if it is necessary. - //asort($language_list); - - // More sanity checks. - if (!array_key_exists($default_language, $language_list)) { - if (array_key_exists('english', $language_list)) { - $default_language = 'english'; - } else { - $language_keys = array_keys($language_list); - $default_language = $language_keys[0]; - } - } - - // Displaying the box. - echo "\t\t\n"; -} - -/** - * This function displays a language dropdown box so that the installatioin - * can be done in the language of the user - */ -function display_language_selection() { ?> -

-

-

:

-
- - - -
-, Ghent University - */ -function display_requirements($installType, $badUpdatePath, $updatePath = '', $update_from_version_8 = array(), $update_from_version_6 = array()) { - echo '

'.display_step_sequence().get_lang('Requirements')."

\n"; - - echo ''.get_lang('ReadThoroughly').'
'; - echo get_lang('MoreDetails').' '.get_lang('ReadTheInstallGuide').'.
'."\n"; - - // SERVER REQUIREMENTS - echo '

'.get_lang('ServerRequirements').'

'; - echo '
'.get_lang('ServerRequirementsInfo').'
'; - echo '
'; - echo ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
'.get_lang('PHPVersion').'>= 5.0'; - if (phpversion() < '5.0') { - echo ''.get_lang('PHPVersionError').''; - } else { - echo ''.get_lang('PHPVersionOK'). ' '.phpversion().''; - } - echo '
Session '.get_lang('support').''.check_extension('session', get_lang('Yes'), get_lang('ExtensionSessionsNotAvailable')).'
MySQL '.get_lang('support').''.check_extension('mysql', get_lang('Yes'), get_lang('ExtensionMySQLNotAvailable')).'
Zlib '.get_lang('support').''.check_extension('zlib', get_lang('Yes'), get_lang('ExtensionZlibNotAvailable')).'
Perl-compatible regular expressions '.get_lang('support').''.check_extension('pcre', get_lang('Yes'), get_lang('ExtensionPCRENotAvailable')).'
XML '.get_lang('support').''.check_extension('xml', get_lang('Yes'), get_lang('No')).'
Multibyte string '.get_lang('support').' ('.get_lang('Optional').')'.check_extension('mbstring', get_lang('Yes'), get_lang('ExtensionMBStringNotAvailable'), true).'
Iconv '.get_lang('support').' ('.get_lang('Optional').')'.check_extension('iconv', get_lang('Yes'), get_lang('No'), true).'
Internationalization '.get_lang('support').' ('.get_lang('Optional').')'.check_extension('intl', get_lang('Yes'), get_lang('No'), true).'
GD '.get_lang('support').''.check_extension('gd', get_lang('Yes'), get_lang('ExtensionGDNotAvailable')).'
JSON '.get_lang('support').''.check_extension('json', get_lang('Yes'), get_lang('No')).'
LDAP '.get_lang('support').' ('.get_lang('Optional').')'.check_extension('ldap', get_lang('Yes'), get_lang('ExtensionLDAPNotAvailable'), true).'
Xapian '.get_lang('support').' ('.get_lang('Optional').')'.check_extension('xapian', get_lang('Yes'), get_lang('No'), true).'
'; - echo '
'; - echo '
'; - - // RECOMMENDED SETTINGS - // Note: these are the settings for Joomla, does this also apply for Dokeos? - // Note: also add upload_max_filesize here so that large uploads are possible - echo '

'.get_lang('RecommendedSettings').'

'; - echo '
'.get_lang('RecommendedSettingsInfo').'
'; - echo '
'; - echo ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
'.get_lang('Setting').''.get_lang('Recommended').''.get_lang('Actual').'
Safe Mode'.check_php_setting('safe_mode','OFF').'
Display Errors'.check_php_setting('display_errors','OFF').'
File Uploads'.check_php_setting('file_uploads','ON').'
Magic Quotes GPC'.check_php_setting('magic_quotes_gpc','OFF').'
Magic Quotes Runtime'.check_php_setting('magic_quotes_runtime','OFF').'
Register Globals'.check_php_setting('register_globals','OFF').'
Session auto start'.check_php_setting('session.auto_start','OFF').'
Short Open Tag'.check_php_setting('short_open_tag','OFF').'
Maximum upload file size'.ini_get('upload_max_filesize').'
Maximum post size'.ini_get('post_max_size').'
'; - echo '
'; - echo '
'; - - // DIRECTORY AND FILE PERMISSIONS - echo '

'.get_lang('DirectoryAndFilePermissions').'

'; - echo '
'.get_lang('DirectoryAndFilePermissionsInfo').'
'; - echo '
'; - echo ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - '. - //' - // - // - //'. - //' - // - // - //'. - ''; - echo '
chamilo/main/inc/conf/'.check_writable('inc/conf/').'
chamilo/main/upload/users/'.check_writable('upload/users/').'
chamilo/main/default_course_document/images/'.check_writable('default_course_document/images/').'
chamilo/archive/'.check_writable('../archive/').'
chamilo/courses/'.check_writable('../courses/').'
chamilo/home/'.check_writable('../home/').'
chamilo/main/css/'.check_writable('css/',true).' ('.get_lang('SuggestionOnlyToEnableCSSUploadFeature').')
chamilo/main/lang/'.check_writable('lang/',true).' ('.get_lang('SuggestionOnlyToEnableSubLanguageFeature').')
dokeos/searchdb/'.check_writable('../searchdb/').'
'.session_save_path().''.(is_writable(session_save_path()) - // ? ''.get_lang('Writable').'' - // : ''.get_lang('NotWritable').'').'
'; - echo '
'; - echo '
'; - - if ($installType == 'update' && (empty($updatePath) || $badUpdatePath)) { - if ($badUpdatePath) { ?> -
- !
- Chamilo . -
- '; - } - ?> - - - - - - - - -
:
- - - -
- the user will have to adjust the permissions manually - if (count($notwritable) > 0) { - $error = true; - echo '
'; - echo get_lang('Warning').':
'; - printf(get_lang('NoWritePermissionPleaseReadInstallGuide'), '', ' '); - echo '
    '; - foreach ($notwritable as $value) { - echo '
  • '.$value.'
  • '; - } - echo '
'; - echo '
'; - } - - // check wether a Chamilo configuration file already exists. - elseif (file_exists('../inc/conf/configuration.php')) { - echo '
'; - echo get_lang('WarningExistingDokeosInstallationDetected'); - echo '
'; - } - - //and now display the choice buttons (go back or install) - ?> -

- - - - '.get_lang('UpgradeFromDokeos18x').''; - echo ''; - echo '

'; - } -} - -/** - * Displays the license (GNU GPL) as step 2, with - * - an "I accept" button named step3 to proceed to step 3; - * - a "Back" button named step1 to go back to the first step. - */ -function display_license_agreement() { - echo '

'.display_step_sequence().get_lang('Licence').'

'; - echo '

'.get_lang('DokeosLicenseInfo').'

'; - echo '

'.get_lang('PrintVers').'

'; - ?> - - - - - -
-

-
-

-
- - - - - -
- - - -
-
- element - * @return void Direct output - */ -function display_database_parameter($install_type, $parameter_name, $form_field_name, $parameter_value, $extra_notice, $display_when_update = true, $tr_attribute = '') { - echo "\n"; - echo "$parameter_name  \n"; - - if ($install_type == INSTALL_TYPE_UPDATE && $display_when_update) { - - echo ''.$parameter_value."\n"; - - } else { - - $inputtype = $form_field_name == 'dbPassForm' ? 'password' : 'text'; - - //Slightly limit the length of the database prefix to avoid having to cut down the databases names later on - $maxlength = $form_field_name == 'dbPrefixForm' ? '15' : MAX_FORM_FIELD_LENGTH; - - echo ''."\n"; - echo "$extra_notice\n"; - } - echo "\n"; -} - -/** - * Displays step 3 - a form where the user can enter the installation settings - * regarding the databases - login and password, names, prefixes, single - * or multiple databases, tracking or not... - */ -function display_database_settings_form($installType, $dbHostForm, $dbUsernameForm, $dbPassForm, $dbPrefixForm, $enableTrackingForm, $singleDbForm, $dbNameForm, $dbStatsForm, $dbScormForm, $dbUserForm) { - - if ($installType == 'update') { - global $_configuration, $update_from_version_6; - - if (in_array($_POST['old_version'], $update_from_version_6)) { - $dbHostForm = get_config_param('dbHost'); - $dbUsernameForm = get_config_param('dbLogin'); - $dbPassForm = get_config_param('dbPass'); - $dbPrefixForm = get_config_param('dbNamePrefix'); - $enableTrackingForm = get_config_param('is_trackingEnabled'); - $singleDbForm = get_config_param('singleDbEnabled'); - $dbNameForm = get_config_param('mainDbName'); - $dbStatsForm = get_config_param('statsDbName'); - $dbScormForm = get_config_param('scormDbName'); - $dbUserForm = get_config_param('user_personal_database'); - $dbScormExists = true; - } else { - $dbHostForm = $_configuration['db_host']; - $dbUsernameForm = $_configuration['db_user']; - $dbPassForm = $_configuration['db_password']; - $dbPrefixForm = $_configuration['db_prefix']; - $enableTrackingForm = $_configuration['tracking_enabled']; - $singleDbForm = $_configuration['single_database']; - $dbNameForm = $_configuration['main_database']; - $dbStatsForm = $_configuration['statistics_database']; - $dbScormForm = $_configuration['scorm_database']; - $dbUserForm = $_configuration['user_personal_database']; - $dbScormExists = true; - } - - if (empty($dbScormForm)) { - if ($singleDbForm) { - $dbScormForm = $dbNameForm; - } else { - $dbScormForm = $dbPrefixForm.'scorm'; - $dbScormExists = false; - } - } - if (empty($dbUserForm)) { - $dbUserForm = $singleDbForm ? $dbNameForm : $dbPrefixForm.'chamilo_user'; - } - echo '

' . display_step_sequence() .get_lang('DBSetting') . '

'; - echo get_lang('DBSettingUpgradeIntro'); - - } else { - - if (empty($dbPrefixForm)) { //make sure there is a default value for db prefix - $dbPrefixForm = 'chamilo_'; - } - echo '

' . display_step_sequence() .get_lang('DBSetting') . '

'; - echo get_lang('DBSettingIntro'); - } - - ?> -

- - - - - - - - - - - - - - - - - - '; - display_database_parameter($installType, get_lang('MainDB'), 'dbNameForm', $dbNameForm, ' ', null, 'id="optional_param1" style="display:none;"'); - display_database_parameter($installType, get_lang('StatDB'), 'dbStatsForm', $dbStatsForm, ' ', null, 'id="optional_param2" style="display:none;"'); - if ($installType == 'update' && in_array($_POST['old_version'], $update_from_version_6)) { - display_database_parameter($installType, get_lang('ScormDB'), 'dbScormForm', $dbScormForm, ' ', null, 'id="optional_param3" style="display:none;"'); - } - display_database_parameter($installType, get_lang('UserDB'), 'dbUserForm', $dbUserForm, ' ', null, 'id="optional_param4" style="display:none;"'); - - ?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
show-hide '.get_lang('OptionalParameters', '').'
-
- - - Database host info:
- Database server version:
- Database client version:
- Database protocol version: - -
-
-
-
- -
- Database error:
- '; ?> -
-
-
-
 
- \n"; - echo "$parameter_name  \n"; - if ($install_type == INSTALL_TYPE_UPDATE && $display_when_update) { - echo ''.$parameter_value."\n"; - } else { - echo ''."\n"; - } - echo "\n"; -} - -/** - * Displays step 4 of the installation - configuration settings about Chamilo itself. - */ -function display_configuration_settings_form($installType, $urlForm, $languageForm, $emailForm, $adminFirstName, $adminLastName, $adminPhoneForm, $campusForm, $institutionForm, $institutionUrlForm, $encryptPassForm, $allowSelfReg, $allowSelfRegProf, $loginForm, $passForm) { - if ($installType != 'update' && empty($languageForm)) { - $languageForm = $_SESSION['install_language']; - } - - echo "

" . display_step_sequence() . get_lang("CfgSetting") . "

"; - echo '

'.get_lang('ConfigSettingsInfo').' main/inc/conf/configuration.php

'; - - echo "\n"; - echo ""; - - //First parameter: language - echo "\n"; - echo '\n"; - - if ($installType == 'update') { - - echo '\n"; - - } else { // new installation - - echo '\n"; - } - echo "\n"; - - //Second parameter: Chamilo URL - echo "\n"; - echo '\n"; - - if ($installType == 'update') { - echo '\n"; - } else { - echo '\n"; - } - - echo "\n"; - - //Parameter 3: administrator's email - display_configuration_parameter($installType, get_lang('AdminEmail'), 'emailForm', $emailForm); - - //Parameters 4 and 5: administrator's names - if (api_is_western_name_order()) { - display_configuration_parameter($installType, get_lang('AdminFirstName'), 'adminFirstName', $adminFirstName); - display_configuration_parameter($installType, get_lang('AdminLastName'), 'adminLastName', $adminLastName); - } else { - display_configuration_parameter($installType, get_lang('AdminLastName'), 'adminLastName', $adminLastName); - display_configuration_parameter($installType, get_lang('AdminFirstName'), 'adminFirstName', $adminFirstName); - } - - //Parameter 6: administrator's telephone - display_configuration_parameter($installType, get_lang('AdminPhone'), 'adminPhoneForm', $adminPhoneForm); - - //Parameter 7: administrator's login - display_configuration_parameter($installType, get_lang('AdminLogin'), 'loginForm', $loginForm, $installType == 'update'); - - //Parameter 8: administrator's password - if ($installType != 'update') { - display_configuration_parameter($installType, get_lang('AdminPass'), 'passForm', $passForm, false); - } - - //Parameter 9: campus name - display_configuration_parameter($installType, get_lang('CampusName'), 'campusForm', $campusForm); - - //Parameter 10: institute (short) name - display_configuration_parameter($installType, get_lang('InstituteShortName'), 'institutionForm', $institutionForm); - - //Parameter 11: institute (short) name - display_configuration_parameter($installType, get_lang('InstituteURL'), 'institutionUrlForm', $institutionUrlForm); - - /* - //old method - - - - - - - - - - - */ - - ?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
'.get_lang('MainLang')."  '.$languageForm."'; - - display_language_selection_box('languageForm', $languageForm); - - echo "
'.get_lang('ChamiloURL').' ('.get_lang('ThisFieldIsRequired').")  '.api_htmlentities($urlForm, ENT_QUOTES)."'."
: - /> - /> -
: - /> - /> - /> -
: - /> - /> -
: - /> - /> -
- -

- - - - MAX_COURSE_TRANSFER): ?> -

- : ', ''); ?> - - -

- '; - //echo ''.get_lang('Warning').''; - echo ''.get_lang('SecurityAdvice').''; - echo ': '; - printf(get_lang('ToProtectYourSiteMakeXAndYReadOnly'), 'main/inc/conf/configuration.php', 'main/install/index.php'); - echo ''; - ?> - - - - $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm)) !== false) { - $dbConnect = 1; - } else { - $dbConnect = -1; - } - } elseif ($singleDbForm == 0) { - if (@Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm)) !== false) { - @Database::query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5) - $multipleDbCheck = @Database::query("CREATE DATABASE ".$dbPrefixForm."test_chamilo_connection"); - if ($multipleDbCheck !== false) { - $multipleDbCheck = @Database::query("DROP DATABASE IF EXISTS ".$dbPrefixForm."test_chamilo_connection"); - if ($multipleDbCheck !== false) { - $dbConnect = 1; - } else { - $dbConnect = 0; - } - } else { - $dbConnect = 0; - } - } else { - $dbConnect = -1; - } - } - return $dbConnect; //return "1"if no problems, "0" if, in case of multiDB we can't create a new DB and "-1" if there is no connection. -} diff --git a/main/install/_install_upgrade.lib.php b/main/install/_install_upgrade.lib.php deleted file mode 100644 index 17763ecdcb..0000000000 --- a/main/install/_install_upgrade.lib.php +++ /dev/null @@ -1,547 +0,0 @@ - $value) { - $content = str_replace($key, $value, $content); - } - - $fp = @ fopen($path, 'w'); - - if (!$fp) { - echo 'Your script doesn\'t have write access to the config directory
- ('.str_replace('\\', '/', realpath($path)).')

- You probably do not have write access on Chamilo root directory, - i.e. you should CHMOD 777 or 755 or 775.

- Your problems can be related on two possible causes:
-
    -
  • Permission problems.
    Try initially with chmod -R 777 and increase restrictions gradually.
  • -
  • PHP is running in Safe-Mode. If possible, try to switch it off.
  • -
- Read about this problem in Support Forum

- Please go back to step 5. -

- '; - exit (); - } - - fwrite($fp, $content); - fclose($fp); -} - -/** - * Creates the structure of the main database and fills it - * with data. Placeholder symbols in the main database file - * have to be replaced by the settings entered by the user during installation. - * - * @param array $installation_settings list of settings entered by the user - * @param string optional path about the script for database - * @return void - */ -function load_main_database($installation_settings, $db_script = '') { - if (!empty($db_script)) { - $sql_text = file_get_contents($db_script); - } else { - $sql_text = file_get_contents(SYSTEM_MAIN_DATABASE_FILE); - } - - //replace symbolic parameters with user-specified values - foreach ($installation_settings as $key => $value) { - $sql_text = str_replace($key, Database::escape_string($value), $sql_text); - } - - //split in array of sql strings - $sql_instructions = array(); - $success = split_sql_file($sql_instructions, $sql_text); - - //execute the sql instructions - $count = count($sql_instructions); - for ($i = 0; $i < $count; $i++) { - $this_sql_query = $sql_instructions[$i]['query']; - Database::query($this_sql_query); - } -} - -/** - * Creates the structure of the stats database - * @param string Name of the file containing the SQL script inside the install directory - */ -function load_database_script($db_script) { - $sql_text = file_get_contents($db_script); - - //split in array of sql strings - $sql_instructions = array(); - $success = split_sql_file($sql_instructions, $sql_text); - - //execute the sql instructions - $count = count($sql_instructions); - for ($i = 0; $i < $count; $i++) { - $this_sql_query = $sql_instructions[$i]['query']; - Database::query($this_sql_query); - } -} - -/** - * Function copied and adapted from phpMyAdmin 2.6.0 PMA_splitSqlFile (also GNU GPL) - * - * Removes comment lines and splits up large sql files into individual queries - * - * Last revision: September 23, 2001 - gandon - * - * @param array the splitted sql commands - * @param string the sql commands - * @param integer the MySQL release number (because certains php3 versions - * can't get the value of a constant from within a function) - * - * @return boolean always true - * - * @access public - */ -function split_sql_file(&$ret, $sql) { - // do not trim, see bug #1030644 - //$sql = trim($sql); - $sql = rtrim($sql, "\n\r"); - $sql_len = strlen($sql); - $char = ''; - $string_start = ''; - $in_string = false; - $nothing = true; - $time0 = time(); - - for ($i = 0; $i < $sql_len; ++$i) { - $char = $sql[$i]; - - // We are in a string, check for not escaped end of strings except for - // backquotes that can't be escaped - if ($in_string) { - for (;;) { - $i = strpos($sql, $string_start, $i); - // No end of string found -> add the current substring to the - // returned array - if (!$i) { - $ret[] = $sql; - return true; - } - // Backquotes or no backslashes before quotes: it's indeed the - // end of the string -> exit the loop - elseif ($string_start == '`' || $sql[$i - 1] != '\\') { - $string_start = ''; - $in_string = false; - break; - } - // one or more Backslashes before the presumed end of string... - else { - // ... first checks for escaped backslashes - $j = 2; - $escaped_backslash = false; - while ($i - $j > 0 && $sql[$i - $j] == '\\') { - $escaped_backslash = !$escaped_backslash; - $j++; - } - // ... if escaped backslashes: it's really the end of the - // string -> exit the loop - if ($escaped_backslash) { - $string_start = ''; - $in_string = false; - break; - } - // ... else loop - else { - $i++; - } - } // end if...elseif...else - } // end for - } // end if (in string) - - // lets skip comments (/*, -- and #) - elseif (($char == '-' && $sql_len > $i + 2 && $sql[$i + 1] == '-' && $sql[$i + 2] <= ' ') || $char == '#' || ($char == '/' && $sql_len > $i + 1 && $sql[$i + 1] == '*')) { - $i = strpos($sql, $char == '/' ? '*/' : "\n", $i); - // didn't we hit end of string? - if ($i === false) { - break; - } - if ($char == '/') $i++; - } - - // We are not in a string, first check for delimiter... - elseif ($char == ';') { - // if delimiter found, add the parsed part to the returned array - $ret[] = array('query' => substr($sql, 0, $i), 'empty' => $nothing); - $nothing = true; - $sql = ltrim(substr($sql, min($i + 1, $sql_len))); - $sql_len = strlen($sql); - if ($sql_len) { - $i = -1; - } else { - // The submited statement(s) end(s) here - return true; - } - } // end elseif (is delimiter) - - // ... then check for start of a string,... - elseif (($char == '"') || ($char == '\'') || ($char == '`')) { - $in_string = true; - $nothing = false; - $string_start = $char; - } // end elseif (is start of string) - - elseif ($nothing) { - $nothing = false; - } - - // loic1: send a fake header each 30 sec. to bypass browser timeout - $time1 = time(); - if ($time1 >= $time0 + 30) { - $time0 = $time1; - header('X-pmaPing: Pong'); - } // end if - } // end for - - // add any rest to the returned array - if (!empty($sql) && preg_match('@[^[:space:]]+@', $sql)) { - $ret[] = array('query' => $sql, 'empty' => $nothing); - } - - return true; -} // end of the 'split_sql_file()' function - -/** - * Get an SQL file's contents - * - * This function bases its parsing on the pre-set format of the specific SQL files in - * the install/upgrade procedure: - * Lines starting with "--" are comments (but need to be taken into account as they also hold sections names) - * Other lines are considered to be one-line-per-query lines (this is checked quickly by this function) - * @param string File to parse (in the current directory) - * @param string Section to return - * @param boolean Print (true) or hide (false) error texts when they occur - */ -function get_sql_file_contents($file, $section, $print_errors = true) { - //check given parameters - if (empty($file)) { - $error = "Missing name of file to parse in get_sql_file_contents()"; - if ($print_errors) echo $error; - return false; - } - if (!in_array($section, array('main', 'user', 'stats', 'scorm', 'course'))) { - $error = "Section '$section' is not authorized in get_sql_file_contents()"; - if ($print_errors) echo $error; - return false; - } - $filepath = getcwd().'/'.$file; - if (!is_file($filepath) or !is_readable($filepath)) { - $error = "File $filepath not found or not readable in get_sql_file_contents()"; - if ($print_errors) echo $error; - return false; - } - //read the file in an array - $file_contents = file($filepath); - if (!is_array($file_contents) or count($file_contents) < 1) { - $error = "File $filepath looks empty in get_sql_file_contents()"; - if ($print_errors) echo $error; - return false; - } - - //prepare the resulting array - $section_contents = array(); - $record = false; - foreach ($file_contents as $index => $line) { - if (substr($line, 0, 2) == '--') { - //This is a comment. Check if section name, otherwise ignore - $result = array(); - if (preg_match('/^-- xx([A-Z]*)xx/', $line, $result)) { //we got a section name here - if ($result[1] == strtoupper($section)) { - //we have the section we are looking for, start recording - $record = true; - } else { - //we have another section's header. If we were recording, stop now and exit loop - if ($record) { - break; - } - $record = false; - } - } - } else { - if ($record) { - if (!empty($line)) { - $section_contents[] = $line; - } - } - } - } - //now we have our section's SQL statements group ready, return - return $section_contents; -} - -/** - * Tries to detect browser's language. - * @return string Returns a language identificator, i.e. 'english', 'spanish', ... - */ -function detect_browser_language() { - static $language_index = array( - 'ar' => 'arabic', - 'ast' => 'asturian', - 'bg' => 'bulgarian', - 'bs' => 'bosnian', - 'ca' => 'catalan', - 'zh' => 'simpl_chinese', - 'zh-tw' => 'trad_chinese', - 'cs' => 'czech', - 'da' => 'danish', - 'prs' => 'dari', - 'de' => 'german', - 'el' => 'greek', - 'en' => 'english', - 'es' => 'spanish', - 'eo' => 'esperanto', - 'eu' => 'euskera', - 'fa' => 'persian', - 'fr' => 'french', - 'fur' => 'friulian', - 'gl' => 'galician', - 'ka' => 'georgian', - 'hr' => 'croatian', - 'he' => 'hebrew', - 'id' => 'indonesian', - 'it' => 'italian', - 'ko' => 'korean', - 'lv' => 'latvian', - 'lt' => 'lithuanian', - 'mk' => 'macedonian', - 'hu' => 'hungarian', - 'ms' => 'malay', - 'nl' => 'dutch', - 'ja' => 'japanese', - 'no' => 'norwegian', - 'oc' => 'occitan', - 'ps' => 'pashto', - 'pl' => 'polish', - 'pt' => 'portuguese', - 'pt-br' => 'brazilian', - 'ro' => 'romanian', - 'qu' => 'quechua_cusco', - 'ru' => 'russian', - 'sk' => 'slovak', - 'sl' => 'slovenian', - 'sr' => 'serbian', - 'fi' => 'finnish', - 'sv' => 'swedish', - 'th' => 'thai', - 'tr' => 'turkce', - 'uk' => 'ukrainian', - 'vi' => 'vietnamese', - 'sw' => 'swahili', - 'yo' => 'yoruba' - ); - - $system_available_languages = & get_language_folder_list(); - - $accept_languages = strtolower(str_replace('_', '-', $_SERVER['HTTP_ACCEPT_LANGUAGE'])); - - foreach ($language_index as $code => $language) { - if (strpos($accept_languages, $code) === 0) { - if (!empty($system_available_languages[$language])) { - return $language; - } - } - } - - $user_agent = strtolower(str_replace('_', '-', $_SERVER['HTTP_USER_AGENT'])); - - foreach ($language_index as $code => $language) { - if (preg_match("/[[( ]{$code}[;,_-)]/", $user_agent)) { - if (!empty($system_available_languages[$language])) { - return $language; - } - } - } - - return 'english'; -} - -/** - * Returns a list of language directories. - */ -function & get_language_folder_list() { - static $result; - if (!is_array($result)) { - $result = array(); - $exceptions = array('.', '..', 'CVS', '.svn'); - $search = array('_latin', '_unicode', '_corporate', '_org' , '_KM', '_'); - $replace_with = array(' (Latin)', ' (unicode)', ' (corporate)', ' (org)', ' (KM)', ' '); - $dirname = api_get_path(SYS_LANG_PATH); - $handle = opendir($dirname); - while ($entries = readdir($handle)) { - if (in_array($entries, $exceptions)) { - continue; - } - if (is_dir($dirname.$entries)) { - $result[$entries] = ucwords(str_replace($search, $replace_with, $entries)); - } - } - closedir($handle); - asort($result); - } - return $result; -} - -// TODO: Maybe within the main API there is already a suitable function? -function my_directory_to_array($directory) { - $array_items = array(); - if ($handle = opendir($directory)) { - while (false !== ($file = readdir($handle))) { - if ($file != "." && $file != "..") { - if (is_dir($directory. "/" . $file)) { - $array_items = array_merge($array_items, my_directory_to_array($directory. '/' . $file)); - $file = $directory . "/" . $file; - $array_items[] = preg_replace("/\/\//si", '/', $file); - } - } - } - closedir($handle); - } - return $array_items; -} - -/** - * Adds a new document to the database - specific to version 1.8.0 - * - * @param array $_course - * @param string $path - * @param string $filetype - * @param int $filesize - * @param string $title - * @return id if inserted document - */ -function add_document_180($_course, $path, $filetype, $filesize, $title, $comment = null) { - $table_document = Database::get_course_table(TABLE_DOCUMENT, $_course['dbName']); - $sql = "INSERT INTO $table_document - (`path`,`filetype`,`size`,`title`, `comment`) - VALUES ('$path','$filetype','$filesize','". - Database::escape_string($title)."', '$comment')"; - if (Database::query($sql)) { - //display_message("Added to database (id ".Database::insert_id().")!"); - return Database::insert_id(); - } else { - //display_error("The uploaded file could not be added to the database (".Database::error().")!"); - return false; - } -} diff --git a/main/install/_update_courses.php b/main/install/_update_courses.php deleted file mode 100644 index 0711f2f9f9..0000000000 --- a/main/install/_update_courses.php +++ /dev/null @@ -1,201 +0,0 @@ - - - - - --- Dokeos course update -- version <?php echo $dokeos_version; ?> - - - - -
- - - - - - - -
- Dokeos course update - version -
- - - - - -

Step 2 of 2 – Course Update

- - courses have been successfully updated. -

- - MAX_COURSE_TRANSFER): ?> - Warning: You have more than courses on your Dokeos platform ! Only courses have been updated. To update the other courses, click here. - -

- - -



- - -
-

- - -

Step 1 of 2 – Configuration

- - Please enter the path where the older version of Dokeos is installed (). The courses will be moved from that location to the Dokeos path. -

- Notice: Please run this update script only if you've just updated (incompletely) Dokeos to Dokeos ! -

- -

-
- Error!
- Dokeos has not been found in that directory. -
- '; - } - ?> - - - - - -
Where are the courses to be updated:
- -

- -

- - -
- - - - diff --git a/main/install/_update_db.inc.php b/main/install/_update_db.inc.php deleted file mode 100644 index e1480152e3..0000000000 --- a/main/install/_update_db.inc.php +++ /dev/null @@ -1,681 +0,0 @@ -'.get_lang('Error').' ! Dokeos '.implode('|', $updateFromVersion).' '.get_lang('HasNotBeenFound').'.

- '.get_lang('PleasGoBackToStep1').'. -

- '; - - exit (); - } - - //get_config_param() comes from install_functions.inc.php and - //actually gets the param from - $_configuration['db_glue'] = get_config_param('dbGlu'); - - if ($singleDbForm) - { - $_configuration['table_prefix'] = get_config_param('courseTablePrefix'); - } - - $dbScormForm = preg_replace('/[^a-zA-Z0-9_\-]/', '', $dbScormForm); - - if (!empty($dbPrefixForm) && strpos($dbScormForm, $dbPrefixForm) !== 0) - { - $dbScormForm = $dbPrefixForm.$dbScormForm; - } - - if (empty($dbScormForm) || $dbScormForm == 'mysql' || $dbScormForm == $dbPrefixForm) - { - $dbScormForm = $dbPrefixForm.'scorm'; - } - - @Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm)); - - //if error on connection to the database, show error and exit - if (Database::errno() > 0) - { - $no = Database::errno(); - $msg = Database::error(); - - echo '
['.$no.'] - '.$msg.'
- '.get_lang('DBServerDoesntWorkOrLoginPassIsWrong').'.

- '.get_lang('PleaseCheckTheseValues').' :

- '.get_lang('DBHost').' : '.$dbHostForm.'
- '.get_lang('DBLogin').' : '.$dbUsernameForm.'
- '.get_lang('DBPassword').' : '.$dbPassForm.'

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

'.get_lang('Back').'

- '; - - exit (); - } - - @Database::query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5) - - /* - ----------------------------------------------------------- - Normal upgrade procedure: - start by updating main, statistic, user databases - ----------------------------------------------------------- - */ - //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('SYSTEM_INSTALLATION')) - { - /** - * Update the databases "pre" migration - */ - include ("../lang/english/create_course.inc.php"); - - if ($languageForm != 'english') - { - //languageForm has been escaped in index.php - include ("../lang/$languageForm/create_course.inc.php"); - } - - //TODO deal with migrate-db-1.6.x-1.8.0-pre.sql here - //get the main queries list (m_q_list) - $m_q_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-pre.sql','main'); - if(count($m_q_list)>0) - { - //now use the $m_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - Database::select_db($dbNameForm); - foreach($m_q_list as $query){ - if($only_test){ - echo "Database::query($dbNameForm,$query)
"; - }else{ - $res = Database::query($query); - } - } - } - //manual updates in here - //update all registration_date, expiration_date and active fields - //$sql_upd = "UPDATE user SET registration_date=NOW()"; - //$res_upd = Database::query($sql_upd); - //end of manual updates - - //get the stats queries list (s_q_list) - $s_q_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-pre.sql','stats'); - if(count($s_q_list)>0) - { - //now use the $s_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - Database::select_db($dbStatsForm); - foreach($s_q_list as $query){ - if($only_test){ - echo "Database::query($dbStatsForm,$query)
"; - }else{ - $res = Database::query($query); - } - } - } - //get the user queries list (u_q_list) - $u_q_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-pre.sql','user'); - if(count($u_q_list)>0) - { - //now use the $u_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - Database::select_db($dbUserForm); - foreach($u_q_list as $query){ - if($only_test){ - echo "Database::query($dbUserForm,$query)
"; - }else{ - $res = Database::query($query); - } - } - } - //the SCORM database doesn't need a change in the pre-migrate part - ignore - - die(); - //TODO only update this table - /* - //set the settings from the form or the old config into config settings. - //These settings are considered "safe" because they are entered by the admin - $installation_settings['institution_form'] = $institutionForm; - $installation_settings['institution_url_form'] = $institutionUrlForm; - $installation_settings['campus_form'] = $campusForm; - $installation_settings['email_form'] = $emailForm; - $installation_settings['admin_last_name'] = $adminLastName; - $installation_settings['admin_first_name'] = $adminFirstName; - $installation_settings['language_form'] = $languageForm; - $installation_settings['allow_self_registration'] = $allowSelfReg; - $installation_settings['allow_teacher_self_registration'] = $allowSelfRegProf; - $installation_settings['admin_phone_form'] = $adminPhoneForm; - - //Database::query("INSERT INTO `$dbNameForm`.`course_module` (`name`,`link`,`image`,`row`,`column`,`position`) VALUES - // ('AddedLearnpath', NULL, 'scormbuilder.gif', 0, 0, 'external'), - // ('".TOOL_BACKUP."', 'coursecopy/backup.php' , 'backup.gif', 2, 1, 'courseadmin'), - // ('".TOOL_COPY_COURSE_CONTENT."', 'coursecopy/copy_course.php' , 'copy.gif', 2, 2, 'courseadmin'), - // ('".TOOL_RECYCLE_COURSE."', 'coursecopy/recycle_course.php' , 'recycle.gif', 2, 3, 'courseadmin')"); - //... - //Database::query("UPDATE `$dbNameForm`.`course_module` SET name='".TOOL_LEARNPATH."' WHERE link LIKE 'scorm/%'"); - */ - } - - /* - ----------------------------------------------------------- - Update the Dokeos course databases - this part can be accessed in two ways: - - from the normal upgrade process - - from the script update_courses.php, - which is used to upgrade more than MAX_COURSE_TRANSFER courses - - Every time this script is accessed, only - MAX_COURSE_TRANSFER courses are upgraded. - ----------------------------------------------------------- - */ - - //get the courses databases queries list (c_q_list) - $c_q_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-pre.sql','course'); - if(count($c_q_list)>0) - { - //get the courses list - Database::select_db($dbNameForm); - $res = Database::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL"); - if($res===false){die('Error while querying the courses list in update_db.inc.php');} - if(Database::num_rows($res)>0) - { - while($row = Database::fetch_array($res)) - { - $list[] = $row; - } - foreach($list as $row) - { - //now use the $c_q_list - /** - * We connect to the right DB first to make sure we can use the queries - * without a database name - */ - Database::select_db($row['db_name']); - foreach($c_q_list as $query) - { - if($only_test) - { - echo "Database::query(".$row['db_name'].",$query)
"; - }else{ - $res = Database::query($query); - } - } - //update course manually - //update group_category.forum_state - //update group_info.tutor_id (put it in group_tutor table?) - //update group_info.forum_state, forum_id - - //update forum tables (migrate from bb_ tables to forum_ tables) - //migrate categories - $sql_orig = "SELECT * FROM bb_categories"; - $res_orig = Database::query($sql_orig); - while($row = Database::fetch_array($res_orig)){ - $sql = "INSERT INTO forum_category " . - "(cat_id,cat_title,cat_comment,cat_order,locked) VALUES " . - "('".$row['cat_id']."','".$row['cat_title']."','','".$row['cat_order']."',0)"; - $res = Database::query($sql); - } - $sql_orig = "SELECT * FROM bb_forums ORDER BY forum_last_post_id desc"; - $res_orig = Database::query($sql_orig); - $order = 1; - while($row = Database::fetch_array($res_orig)){ - $sql = "INSERT INTO forum_forum " . - "(forum_id,forum_category,allow_edit,forum_comment," . - "forum_title," . - "forum_last_post, forum_threads," . - "locked, forum_posts, " . - "allow_new_threads, forum_order) VALUES " . - "('".$row['forum_id']."','".$row['cat_id']."',1,'".$row['forum_desc']."'," . - "'".$row['forum_name']."'," . - "'".$row['forum_last_post_id']."','".$row['forum_topics']."'," . - "0,'".$row['forum_posts']."'," . - "1,$order)"; - $res = Database::query($sql); - $order++; - } - $sql_orig = "SELECT * FROM bb_topics"; - $res_orig = Database::query($sql_orig); - while($row = Database::fetch_array($res_orig)){ - //convert time from varchar to datetime - $time = $row['topic_time']; - $name = $row['prenom']." ".$row['nom']; - $sql = "INSERT INTO forum_thread " . - "(thread_id,forum_id,thread_poster_id," . - "locked,thread_replies,thread_sticky,thread_title," . - "thread_poster_name, thread_date, thread_last_post," . - "thread_views) VALUES " . - "('".$row['topic_id']."','".$row['forum_id']."','".$row['topic_poster']."'," . - "0,'".$row['topic_replies']."',0,'".$row['topic_title']."'," . - "'$name','$time','".$row['topic_last_post_id']."'," . - "'".$row['topic_views']."')"; - $res = Database::query($sql); - } - $sql_orig = "SELECT * FROM bb_posts, bb_posts_text WHERE bb_posts.post_id = bb_posts_text.post_id"; - $res_orig = Database::query($sql_orig); - while($row = Database::fetch_array($res_orig)){ - //convert time from varchar to datetime - $time = $row['post_time']; - $name = $row['prenom']." ".$row['nom']; - $sql = "INSERT INTO forum_post " . - "(post_id,forum_id,thread_id," . - "poster_id,post_parent_id,visible, " . - "post_title,poster_name, post_text, " . - "post_date, post_notification) VALUES " . - "('".$row['post_id']."','".$row['forum_id']."','".$row['topic_id']."'," . - "'".$row['poster_id']."','".$row['parent_id']."',1," . - "'".$row['post_title']."','$name', '".$row['post_text']."'," . - "'$time',0)"; - $res = Database::query($sql); - } - } - } - } - - $newPath = str_replace('\\', '/', realpath('../..')).'/'; - - $coursePath = array (); - $courseDB = array (); - $nbr_courses = 0; - - if ($result = Database::query("SELECT code,db_name,directory,course_language FROM `$dbNameForm`.`course` WHERE target_course_code IS NULL")) - { - $i = 0; - - $nbr_courses = Database::num_rows($result); - - while ($i < MAX_COURSE_TRANSFER && (list ($course_code, $db_base_course, $directory, $languageCourse) = Database::fetch_row($result))) - { - if (!file_exists($newPath.'courses/'.$directory)) - { - if ($singleDbForm) - { - $prefix = $_configuration['table_prefix'].$db_base_course.$_configuration['db_glue']; - - $db_base_course = $dbNameForm.'`.`'.$_configuration['table_prefix'].$db_base_course; - } - else - { - $prefix = ''; - } - - $coursePath[$course_code] = $directory; - $courseDB[$course_code] = $db_base_course; - - include ("../lang/english/create_course.inc.php"); - - if ($languageCourse != 'english') - { - include ("../lang/$languageCourse/create_course.inc.php"); - } - - //TODO process the whole course database migration here. Call an external - //script/function to keep this script tidy - - // Set item-properties of dropbox files - /* - $sql = "SELECT * FROM `$db_base_course".$_configuration['db_glue']."dropbox_file` f, `".$_configuration['db_glue']."_base_course".$_configuration['db_glue']."dropbox_post` p WHERE f.id = p.file_id"; - $res = Database::query($sql); - while ($obj = Database::fetch_object($res)) - { - $sql = "INSERT INTO `$db_base_course".$_configuration['db_glue']."item_property` SET "; - $sql .= " tool = '".TOOL_DROPBOX."', "; - $sql .= " insert_date = '".$obj->upload_date."', "; - $sql .= " lastedit_date = '".$obj->last_upload_date."', "; - $sql .= " ref = '".$obj->id."', "; - $sql .= " lastedit_type = 'DropboxFileAdded', "; - $sql .= " to_group_id = '0', "; - $sql .= " to_user_id = '".$obj->dest_user_id."', "; - $sql .= " insert_user_id = '".$obj->uploader_id."'"; - Database::query($sql); - } - */ - - $i ++; - } - else - { - $nbr_courses --; - } - } - } -} -else -{ - echo 'You are not allowed here !'; -} - - - - - - - - -/** -* This function stores the forum category in the database. The new category is added to the end. -* @author Patrick Cool , Ghent University -* @todo is this the same function as in forumfunction.inc.php? If this is the case then it should not appear here. -*/ -function store_forumcategory($values) -{ - global $table_categories; - global $_course; - global $_user; - - // find the max cat_order. The new forum category is added at the end => max cat_order + & - $sql="SELECT MAX(cat_order) as sort_max FROM ".Database::escape_string($table_categories); - $result=Database::query($sql); - $row=Database::fetch_array($result); - $new_max=$row['sort_max']+1; - - $sql="INSERT INTO ".$table_categories." (cat_title, cat_comment, cat_order) VALUES ('".Database::real_escape_string($values['forum_category_title'])."','".Database::escape_string($values['forum_category_comment'])."','".Database::escape_string($new_max)."')"; - Database::query($sql); - $last_id=Database::insert_id(); - api_item_property_update($_course, TOOL_FORUM_CATEGORY, $last_id,"ForumCategoryAdded", $_user['user_id']); - return array('id'=>$last_id,'title'=>$values['forum_category_title']) ; -} - -/** -* This function stores the forum in the database. The new forum is added to the end. -* @author Patrick Cool , Ghent University -* @todo is this the same function as in forumfunction.inc.php? If this is the case then it should not appear here. -*/ -function store_forum($values) -{ - global $table_forums; - global $_course; - global $_user; - - // find the max forum_order for the given category. The new forum is added at the end => max cat_order + & - $sql="SELECT MAX(forum_order) as sort_max FROM ".$table_forums." WHERE forum_category=".Database::escape_string($values['forum_category']); - $result=Database::query($sql); - $row=Database::fetch_array($result); - $new_max=$row['sort_max']+1; - - - $sql="INSERT INTO ".$table_forums." - (forum_title, forum_comment, forum_category, allow_anonymous, allow_edit, approval_direct_post, allow_attachments, allow_new_threads, default_view, forum_of_group, forum_group_public_private, forum_order) - VALUES ('".Database::escape_string($values['forum_title'])."', - '".Database::escape_string($values['forum_comment'])."', - '".Database::escape_string($values['forum_category'])."', - '".Database::escape_string($values['allow_anonymous_group']['allow_anonymous'])."', - '".Database::escape_string($values['students_can_edit_group']['students_can_edit'])."', - '".Database::escape_string($values['approval_direct_group']['approval_direct'])."', - '".Database::escape_string($values['allow_attachments_group']['allow_attachments'])."', - '".Database::escape_string($values['allow_new_threads_group']['allow_new_threads'])."', - '".Database::escape_string($values['default_view_type_group']['default_view_type'])."', - '".Database::escape_string($values['group_forum'])."', - '".Database::escape_string($values['public_private_group_forum_group']['public_private_group_forum'])."', - '".Database::escape_string($new_max)."')"; - Database::query($sql); - $last_id=Database::insert_id(); - api_item_property_update($_course, TOOL_FORUM, $last_id,"ForumCategoryAdded", $_user['user_id']); - return array('id'=>$last_id, 'title'=>$values['forum_title']); -} - -/** -* This function stores a new thread. This is done through an entry in the forum_thread table AND -* in the forum_post table because. The threads are also stored in the item_property table. (forum posts are not (yet)) -* @author Patrick Cool , Ghent University -* @todo is this the same function as in forumfunction.inc.php? If this is the case then it should not appear here. -*/ -function store_thread($values) -{ - global $table_threads; - global $table_posts; - global $_user; - global $_course; - global $current_forum; - - // We first store an entry in the forum_thread table because the thread_id is used in the forum_post table - $sql="INSERT INTO $table_threads (thread_title, forum_id, thread_poster_id, thread_poster_name, thread_views, thread_date, thread_sticky) - VALUES ('".Database::escape_string($values['post_title'])."', - '".Database::escape_string($values['forum_id'])."', - '".Database::escape_string($values['user_id'])."', - '".Database::escape_string($values['poster_name'])."', - '".Database::escape_string($values['topic_views'])."', - '".Database::escape_string($values['post_date'])."', - '".Database::escape_string($values['thread_sticky'])."')"; - $result=Database::query($sql); - $last_thread_id=Database::insert_id(); - api_item_property_update($_course, TOOL_FORUM_THREAD, $last_thread_id,"ForumThreadAdded", $_user['user_id']); - // if the forum properties tell that the posts have to be approved we have to put the whole thread invisible - // because otherwise the students will see the thread and not the post in the thread. - // we also have to change $visible because the post itself has to be visible in this case (otherwise the teacher would have - // to make the thread visible AND the post - if ($values['visible']==0) - { - api_item_property_update($_course, TOOL_FORUM_THREAD, $last_thread_id,"invisible", $_user['user_id']); - $visible=1; - } - - return $last_thread_id; -} - -/** -* This function migrates the threads of a given phpbb forum to a new forum of the new forum tool -* @param $phpbb_forum_id the forum_id of the old (phpbb) forum -* @param $new_forum_id the forum_id in the new forum -* @author Patrick Cool , Ghent University -* @todo is this the same function as in forumfunction.inc.php? If this is the case then it should not appear here. -*/ -function migrate_threads_of_forum($phpbb_forum_id, $new_forum_id) -{ - global $phpbb_threads; - global $table_forums; - - $table_users = Database :: get_main_table(TABLE_MAIN_USER); - - $sql_phpbb_threads="SELECT forum.*, users.user_id - FROM $phpbb_threads forum, $table_users users - WHERE forum_id='".Database::escape_string($phpbb_forum_id)."' - AND forum.nom=users.lastname AND forum.prenom=users.firstname - "; - $result_phpbb_threads=Database::query($sql_phpbb_threads); - $threads_counter=0; - while ($row_phpbb_threads=Database::fetch_array($result_phpbb_threads)) - { - $values['post_title']=$row_phpbb_threads['topic_title']; - $values['forum_id']=$new_forum_id; - $values['user_id']=$row_phpbb_threads['user_id']; - $values['poster_name']=0; - $values['topic_views']=$row_phpbb_threads['topic_views']; - $values['post_date']=$row_phpbb_threads['topic_time']; - $values['thread_sticky']=0; - $values['visible']=$row_phpbb_threads['visible']; - //my_print_r($values); - $new_forum_thread_id=store_thread($values); - - // now we migrate the posts of the given thread - $posts_counter=$posts_counter+migrate_posts_of_thread($row_phpbb_threads['topic_id'], $new_forum_thread_id, $new_forum_id); - - $threads_counter++; - } - - // Now we update the forum_forum table with the total number of posts for the given forum. - $sql="UPDATE $table_forums - SET forum_posts='".Database::escape_string($posts_counter)."', - forum_threads='".Database::escape_string($threads_counter)."' - WHERE forum_id='".Database::escape_string($new_forum_id)."'"; - //echo $sql; - $result=Database::query($sql); - return array("threads"=>$threads_counter, "posts"=>$posts_counter); -} - -/** -* This function migrates the posts of a given phpbb thread (topic) to a thread in the new forum tool -* @param $phpbb_forum_id the forum_id of the old (phpbb) forum -* @param $new_forum_id the forum_id in the new forum -* @author Patrick Cool , Ghent University -* @todo is this the same function as in forumfunction.inc.php? If this is the case then it should not appear here. -*/ -function migrate_posts_of_thread($phpbb_thread_id, $new_forum_thread_id, $new_forum_id) -{ - global $phpbb_posts; - global $phpbb_poststext; - global $table_posts; - global $table_threads; - global $added_resources; - - $table_users = Database :: get_main_table(TABLE_MAIN_USER); - $table_added_resources = Database::get_course_table(TABLE_LINKED_RESOURCES); - - - $post_counter=0; - - $sql_phpbb_posts="SELECT posts.*, posts_text.*, users.user_id, users.lastname, users.firstname FROM $phpbb_posts posts, $phpbb_poststext posts_text, $table_users users - WHERE posts.post_id=posts_text.post_id - AND posts.nom=users.lastname - AND posts.prenom=users.firstname - AND posts.topic_id='".Database::escape_string($phpbb_thread_id)."' - "; - $result_phpbb_posts=Database::query($sql_phpbb_posts); - while($row_phpbb_posts=Database::fetch_array($result_phpbb_posts)) - { - $values=array(); - $values['post_title']=$row_phpbb_posts['post_title']; - $values['post_text']=$row_phpbb_posts['post_text']; - $values['thread_id']=$new_forum_thread_id; - $values['forum_id']=$new_forum_id; - $values['user_id']=$row_phpbb_posts['user_id']; - $values['post_date']=$row_phpbb_posts['post_time']; - $values['post_notification']=$row_phpbb_posts['topic_notify']; - $values['post_parent_id']=0; - $values['visible']=1; - - // We first store an entry in the forum_post table - $sql="INSERT INTO $table_posts (post_title, post_text, thread_id, forum_id, poster_id, post_date, post_notification, post_parent_id, visible) - VALUES ('".Database::escape_string($values['post_title'])."', - '".Database::escape_string($values['post_text'])."', - '".Database::escape_string($values['thread_id'])."', - '".Database::escape_string($values['forum_id'])."', - '".Database::escape_string($values['user_id'])."', - '".Database::escape_string($values['post_date'])."', - '".Database::escape_string($values['post_notification'])."', - '".Database::escape_string($values['post_parent_id'])."', - '".Database::escape_string($values['visible'])."')"; - $result=Database::query($sql); - $post_counter++; - $last_post_id=Database::insert_id(); - - - // We check if there added resources and if so we update them - if (in_array($row_phpbb_posts['post_id'],$added_resources)) - { - $sql_update_added_resource="UPDATE $table_added_resources - SET source_type='forum_post', source_id='".Database::escape_string($last_post_id)."' - WHERE source_type='".Database::escape_string(TOOL_BB_POST)."' AND source_id='".Database::escape_string($row_phpbb_posts['post_id'])."'"; - echo $sql_update_added_resource; - $result=Database::query($sql_update_added_resource); - } - - - } - - // update the thread_last_post of the post table AND the - $sql="UPDATE $table_threads SET thread_last_post='".Database::escape_string($last_post_id)."', - thread_replies='".Database::escape_string($post_counter-1)."' - WHERE thread_id='".Database::escape_string($new_forum_thread_id)."'"; - //echo $sql; - $result=Database::query($sql); - //echo $sql; - return $post_counter; -} - -/** -* This function gets all the added resources for phpbb forum posts -* @author Patrick Cool , Ghent University -* @todo is this the same function as in forumfunction.inc.php? If this is the case then it should not appear here. -*/ -function get_added_resources() -{ - $table_added_resources = Database::get_course_table(TABLE_LINKED_RESOURCES); - $return_array=array(); - - // TODO: now we also migrate the added resources. - $sql_added_resources="SELECT * FROM $table_added_resources WHERE source_type='".Database::escape_string(TOOL_BB_POST)."'"; - $result=Database::query($sql_added_resources); - while ($row=Database::fetch_array($result)) - { - $return_array[]=$row['source_id']; - } - return $return_array; -} - -/** -* This function gets the forum category information based on the name -* @author Patrick Cool , Ghent University -* @todo is this the same function as in forumfunction.inc.php? If this is the case then it should not appear here. -*/ -function get_forumcategory_id_by_name($forum_category_name) -{ - global $table_categories; - - $sql="SELECT cat_id FROM $table_categories WHERE cat_title='".Database::escape_string($forum_category_name)."'"; - //echo $sql; - $result=Database::query($sql); - $row=Database::fetch_array($result); - //echo $row['cat_id']; - return $row['cat_id']; -} -?> diff --git a/main/install/_update_files.inc.php b/main/install/_update_files.inc.php deleted file mode 100644 index c8617b1a31..0000000000 --- a/main/install/_update_files.inc.php +++ /dev/null @@ -1,228 +0,0 @@ - $course) { - $db_base_course = $courseDB[$key]; - @ unlink($oldPath.$course.'/document/.htaccess'); - @ unlink($oldPath.$course.'/group/index.php'); - - if ($fp = @ fopen($oldPath.$course.'/group/index.php', 'w')) { - fputs($fp, ''); - fclose($fp); - } - @ unlink($oldPath.$course.'/index.php'); - - if ($fp = @ fopen($oldPath.$course.'/index.php', 'w')) { - fputs($fp, ''); - - fclose($fp); - } - - @ mkdir($oldPath.$course.'/temp', $perm); - @ chmod($oldPath.$course.'/temp', $perm); - @ rename($oldPath.$course, $newPath.'courses/'.$course); - - // Move group documents to document folder of the course - $group_dir = $newPath.'courses/'.$course.'/group'; - - if ($dir = @ opendir($group_dir)) { - while (($entry = readdir($dir)) !== false) { - if ($entry != '.' && $entry != '..' && is_dir($group_dir.'/'.$entry)) { - $from_dir = $group_dir.'/'.$entry; - $to_dir = $newPath.'courses/'.$course.'/document/'.$entry; - @ rename($from_dir, $to_dir); - } - } - closedir($dir); - } - - fill_document_table($newPath.'courses/'.$course.'/document'); - - Database::query("ALTER TABLE `$db_base_course".$_configuration['db_glue']."document` DROP `visibility`"); - - // Update item_properties of group documents - $sql = "SELECT d.id AS doc_id, g.id AS group_id FROM `$db_base_course".$_configuration['db_glue']."group_info` g,`$db_base_course".$_configuration['db_glue']."document` d WHERE path LIKE CONCAT(g.secret_directory,'%')"; - $res = Database::query($sql); - - while ($group_doc = Database::fetch_object($res)) { - $sql = "UPDATE `$db_base_course".$_configuration['db_glue']."item_property` SET to_group_id = '".$group_doc->group_id."', visibility = '1' WHERE ref = '".$group_doc->doc_id."' AND tool = '".TOOL_DOCUMENT."'"; - Database::query($sql); - } - } - - if (defined('SYSTEM_INSTALLATION')) { - - // Write the Dokeos config file - write_system_config_file($newPath.'main/inc/conf/configuration.php'); - - // Write a distribution file with the config as a backup for the admin - write_system_config_file($newPath.'main/inc/conf/configuration.dist.php'); - - // Write a .htaccess file in the course repository - write_courses_htaccess_file($urlAppendPath); - - require_once ('../inc/lib/fileManage.lib.php'); - - // First remove the upload/users directory in the new installation - removeDir($newPath.'main/upload/users'); - - // Move the old user images to the new installation - @ rename($oldPath.'main/img/users', $newPath.'main/upload/users'); - - if (!@ rename($oldPath.'main/inc/conf/configuration.php', $oldPath.'main/inc/conf/configuration.php.old')) - { - unlink($oldPath.'main/inc/conf/configuration.php'); - } - } -} else { - echo 'You are not allowed here !'; -} diff --git a/main/install/_upgrade.php b/main/install/_upgrade.php deleted file mode 100644 index 8af383fab1..0000000000 --- a/main/install/_upgrade.php +++ /dev/null @@ -1,839 +0,0 @@ -_formBuilt = true; - $this->addElement('select', 'install_language', get_lang('InstallationLanguage'), get_language_folder_list()); - $buttons[0] = & HTML_QuickForm :: createElement('submit', $this->getButtonName('next'), get_lang('Next').' >>'); - $this->addGroup($buttons, 'buttons', '', ' ', false); - $this->setDefaultAction('next'); - } -} - -/** - * Class for requirements page - * This checks and informs about some requirements for installing Dokeos: - * - necessary and optional extensions - * - folders which have to be writable - */ -class Page_Requirements extends HTML_QuickForm_Page { - - /** - * this function checks if a php extension exists or not - * - * @param string $extentionName name of the php extension to be checked - * @param boolean $echoWhenOk true => show ok when the extension exists - * @author Christophe Gesché - */ - function check_extension($extentionName) { - if (extension_loaded($extentionName)) { - return '
  • '.$extentionName.' - ok
  • '; - } else { - return '
  • '.$extentionName.' is missing (Dokeos can work without) ('.$extentionName.')
  • '; - } - } - - function get_not_writable_folders() { - $writable_folders = array('../inc/conf', '../upload', '../../archive', '../../courses', '../../home'); - $not_writable = array(); - $perm = api_get_permissions_for_new_directories(); - foreach ($writable_folders as $index => $folder) { - if (!is_writable($folder) && !@ chmod($folder, $perm)) { - $not_writable[] = $folder; - } - } - return $not_writable; - } - - function get_title() { - return get_lang("Requirements"); - } - - function get_info() { - $not_writable = $this->get_not_writable_folders(); - - if (count($not_writable) > 0) { - $info[] = '
    '; - $info[] = 'Some files or folders don\'t have writing permission. To be able to install Dokeos you should first change their permissions (using CHMOD). Please read the installation guide.'; - $info[] = '
      '; - foreach ($not_writable as $index => $folder) { - $info[] = '
    • '.$folder.'
    • '; - } - $info[] = '
    '; - $info[] = '
    '; - $this->disableNext = true; - } elseif (file_exists('../inc/conf/claro_main.conf.php')) { - $info[] = '
    '; - $info[] = get_lang("WarningExistingDokeosInstallationDetected"); - $info[] = '
    '; - } - $info[] = ''.get_lang("ReadThoroughly").''; - $info[] = '
    '; - $info[] = get_lang("DokeosNeedFollowingOnServer"); - $info[] = "
      "; - $info[] = "
    • Webserver with PHP 5.x"; - $info[] = '
        '; - $info[] = $this->check_extension('standard'); - $info[] = $this->check_extension('session'); - $info[] = $this->check_extension('mysql'); - $info[] = $this->check_extension('zlib'); - $info[] = $this->check_extension('pcre'); - $info[] = '
    • '; - $info[] = "
    • MySQL + login/password allowing to access and create at least one database
    • "; - $info[] = "
    • Write access to web directory where Dokeos files have been put
    • "; - $info[] = "
    "; - $info[] = get_lang('MoreDetails').", read the installation guide."; - return implode("\n",$info); - } - - function buildForm() { - global $updateFromVersion; - $this->_formBuilt = true; - $this->addElement('radio', 'installation_type', get_lang('InstallType'), get_lang('NewInstall'), 'new'); - $update_group[0] = & HTML_QuickForm :: createElement('radio', 'installation_type', null, 'Update from Dokeos '.implode('|', $updateFromVersion).'', 'update'); - //$this->addGroup($update_group, 'update_group', '', ' ', false); - $prevnext[] = & $this->createElement('submit', $this->getButtonName('back'), '<< '.get_lang('Previous')); - $prevnext[] = & $this->createElement('submit', $this->getButtonName('next'), get_lang('Next').' >>'); - $not_writable = $this->get_not_writable_folders(); - if (count($not_writable) > 0) { - $el = $prevnext[1]; - $el->updateAttributes('disabled="disabled"'); - } - $this->addGroup($prevnext, 'buttons', '', ' ', false); - $this->setDefaultAction('next'); - } -} - -/** - * Page in the install wizard to select the location of the old Dokeos installation. - */ -class Page_LocationOldVersion extends HTML_QuickForm_Page { - - function get_title() { - return 'Old version root path'; - } - - function get_info() { - return 'Give location of your old Dokeos installation '; - } - - function buildForm() { - $this->_formBuilt = true; - $this->addElement('text', 'old_version_path', 'Old version root path'); - $this->applyFilter('old_version_path', 'trim'); - $this->addRule('old_version_path', get_lang('ThisFieldIsRequired'), 'required'); - $this->addRule('old_version_path', get_lang('BadUpdatePath'), 'callback', 'check_update_path'); - $prevnext[] = & $this->createElement('submit', $this->getButtonName('back'), '<< '.get_lang('Previous')); - $prevnext[] = & $this->createElement('submit', $this->getButtonName('next'), get_lang('Next').' >>'); - $this->addGroup($prevnext, 'buttons', '', ' ', false); - $this->setDefaultAction('next'); - } -} - -/** - * Class for license page - * Displays the GNU GPL license that has to be accepted to install Dokeos. - */ -class Page_License extends HTML_QuickForm_Page { - function get_title() { - return get_lang('Licence'); - } - - function get_info() { - return get_lang('DokeosLicenseInfo'); - } - - function buildForm() { - $this->_formBuilt = true; - $this->addElement('textarea', 'license', get_lang('Licence'), array ('cols' => 80, 'rows' => 20, 'disabled' => 'disabled', 'style'=>'background-color: white;')); - $this->addElement('checkbox','license_accept','',get_lang('IAccept')); - $this->addRule('license_accept',get_lang('ThisFieldIsRequired'),'required'); - $prevnext[] = & $this->createElement('submit', $this->getButtonName('back'), '<< '.get_lang('Previous')); - $prevnext[] = & $this->createElement('submit', $this->getButtonName('next'), get_lang('Next').' >>'); - $this->addGroup($prevnext, 'buttons', '', ' ', false); - $this->setDefaultAction('next'); - } -} - -/** - * Class for database settings page - * Displays a form where the user can enter the installation settings - * regarding the databases - login and password, names, prefixes, single - * or multiple databases, tracking or not... - */ -class Page_DatabaseSettings extends HTML_QuickForm_Page { - - function get_title() { - return get_lang('DBSetting'); - } - - function get_info() { - return get_lang('DBSettingIntro'); - } - - function buildForm() { - $this->_formBuilt = true; - $this->addElement('text', 'database_host', get_lang("DBHost"), array ('size' => '40')); - $this->addRule('database_host', 'ThisFieldIsRequired', 'required'); - $this->addElement('text', 'database_username', get_lang("DBLogin"), array ('size' => '40')); - $this->addElement('password', 'database_password', get_lang("DBPassword"), array ('size' => '40')); - $this->addRule(array('database_host','database_username','database_password'),get_lang('CouldNotConnectToDatabase'),new ValidateDatabaseConnection()); - $this->addElement('text', 'database_prefix', get_lang("DbPrefixForm"), array ('size' => '40')); - $this->addElement('text', 'database_main_db', get_lang("MainDB"), array ('size' => '40')); - $this->addRule('database_main_db', 'ThisFieldIsRequired', 'required'); - $this->addElement('text', 'database_tracking', get_lang("StatDB"), array ('size' => '40')); - $this->addRule('database_tracking', 'ThisFieldIsRequired', 'required'); - $this->addElement('text', 'database_scorm', get_lang("ScormDB"), array ('size' => '40')); - $this->addRule('database_scorm', 'ThisFieldIsRequired', 'required'); - $this->addElement('text', 'database_user', get_lang("UserDB"), array ('size' => '40')); - $this->addRule('database_user', 'ThisFieldIsRequired', 'required'); - //$this->addElement('text', 'database_repository', get_lang("RepositoryDatabase"), array ('size' => '40')); - //$this->addRule('database_repository', 'ThisFieldIsRequired', 'required'); - //$this->addElement('text', 'database_weblcms', get_lang("WeblcmsDatabase"), array ('size' => '40')); - //$this->addRule('database_weblcms', 'ThisFieldIsRequired', 'required'); - //$this->addElement('text', 'database_personal_calendar', get_lang("PersonalCalendarDatabase"), array ('size' => '40')); - //$this->addRule('database_personal_calendar', 'ThisFieldIsRequired', 'required'); - //$this->addElement('text', 'database_personal_messenger', get_lang("PersonalMessageDatabase"), array ('size' => '40')); - //$this->addRule('database_personal_messenger', 'ThisFieldIsRequired', 'required'); - //$this->addElement('text', 'database_profiler', get_lang("ProfilerDatabase"), array ('size' => '40')); - //$this->addRule('database_profiler', 'ThisFieldIsRequired', 'required'); - - $enable_tracking[] = & $this->createElement('radio', 'enable_tracking', null, get_lang("Yes"), 1); - $enable_tracking[] = & $this->createElement('radio', 'enable_tracking', null, get_lang("No"), 0); - $this->addGroup($enable_tracking, 'tracking', get_lang("EnableTracking"), ' ', false); - $several_db[] = & $this->createElement('radio', 'database_single', null, get_lang("One"), 1); - $several_db[] = & $this->createElement('radio', 'database_single', null, get_lang("Several"), 0); - $this->addGroup($several_db, 'db', get_lang("SingleDb"), ' ', false); - $prevnext[] = & $this->createElement('submit', $this->getButtonName('back'), '<< '.get_lang('Previous')); - $prevnext[] = & $this->createElement('submit', $this->getButtonName('next'), get_lang('Next').' >>'); - $this->addGroup($prevnext, 'buttons', '', ' ', false); - $this->setDefaultAction('next'); - } -} - -class ValidateDatabaseConnection extends HTML_QuickForm_Rule { - - public function validate($parameters) { - return Database::connect(array('server' => $parameters[0], 'username' => $parameters[1], 'password' => $parameters[2])) !== false; - } -} - -/** - * Page in the install wizard in which some config settings are asked to the - * user. - */ -class Page_ConfigSettings extends HTML_QuickForm_Page { - - function get_title() { - return get_lang('CfgSetting'); - } - - function get_info() { - return get_lang('ConfigSettingsInfo'); - } - - function buildForm() { - $this->_formBuilt = true; - $languages = array (); - $languages['dutch'] = 'dutch'; - $this->addElement('select', 'platform_language', get_lang("MainLang"), get_language_folder_list()); - $this->addElement('text', 'platform_url', get_lang("DokeosURL"), array ('size' => '40')); - $this->addRule('platform_url', get_lang('ThisFieldIsRequired'), 'required'); - $this->addElement('text', 'admin_email', get_lang("AdminEmail"), array ('size' => '40')); - $this->addRule('admin_email', get_lang('ThisFieldIsRequired'), 'required'); - $this->addRule('admin_email', get_lang('WrongEmail'), 'email'); - $this->addElement('text', 'admin_lastname', get_lang("AdminLastName"), array ('size' => '40')); - $this->addRule('admin_lastname', get_lang('ThisFieldIsRequired'), 'required'); - $this->addElement('text', 'admin_firstname', get_lang("AdminFirstName"), array ('size' => '40')); - $this->addRule('admin_firstname', get_lang('ThisFieldIsRequired'), 'required'); - $this->addElement('text', 'admin_phone', get_lang("AdminPhone"), array ('size' => '40')); - $this->addElement('text', 'admin_username', get_lang("AdminLogin"), array ('size' => '40')); - $this->addRule('admin_username', get_lang('ThisFieldIsRequired'), 'required'); - $this->addElement('text', 'admin_password', get_lang("AdminPass"), array ('size' => '40')); - $this->addRule('admin_password', get_lang('ThisFieldIsRequired'), 'required'); - $this->addElement('text', 'platform_name', get_lang("CampusName"), array ('size' => '40')); - $this->addRule('platform_name', get_lang('ThisFieldIsRequired'), 'required'); - $this->addElement('text', 'organization_name', get_lang("InstituteShortName"), array ('size' => '40')); - $this->addRule('organization_name', get_lang('ThisFieldIsRequired'), 'required'); - $this->addElement('text', 'organization_url', get_lang("InstituteURL"), array ('size' => '40')); - $this->addRule('organization_url', get_lang('ThisFieldIsRequired'), 'required'); - $encrypt[] = & $this->createElement('radio', 'encrypt_password', null, get_lang('Yes'), 1); - $encrypt[] = & $this->createElement('radio', 'encrypt_password', null, get_lang('No'), 0); - $this->addGroup($encrypt, 'tracking', get_lang("EncryptUserPass"), ' ', false); - $self_reg[] = & $this->createElement('radio', 'self_reg', null, get_lang('Yes'), 1); - $self_reg[] = & $this->createElement('radio', 'self_reg', null, get_lang('No'), 0); - $this->addGroup($self_reg, 'tracking', get_lang("AllowSelfReg"), ' ', false); - $self_reg_teacher[] = & $this->createElement('radio', 'self_reg_teacher', null, get_lang('Yes'), 1); - $self_reg_teacher[] = & $this->createElement('radio', 'self_reg_teacher', null, get_lang('No'), 0); - $this->addGroup($self_reg_teacher, 'tracking', get_lang("AllowSelfRegProf"), ' ', false); - $prevnext[] = & $this->createElement('submit', $this->getButtonName('back'), '<< '.get_lang('Previous')); - $prevnext[] = & $this->createElement('submit', $this->getButtonName('next'), get_lang('Next').' >>'); - $this->addGroup($prevnext, 'buttons', '', ' ', false); - $this->setDefaultAction('next'); - } -} - -/** - * Page in the install wizard in which a final overview of all settings is - * displayed. - */ -class Page_ConfirmSettings extends HTML_QuickForm_Page { - - function get_title() { - return get_lang('LastCheck'); - } - - function get_info() { - return 'Here are the values you entered -
    - Print this page to remember your password and other settings'; - } - - function buildForm() { - $wizard = $this->controller; - $values = $wizard->exportValues(); - $this->addElement('static', 'confirm_platform_language', get_lang("MainLang"), $values['platform_language']); - $this->addElement('static', 'confirm_platform_url', get_lang("DokeosURL"), $values['platform_url']); - $this->addElement('static', 'confirm_admin_email', get_lang("AdminEmail"), $values['admin_email']); - $this->addElement('static', 'confirm_admin_lastname', get_lang("AdminLastName"), $values['admin_lastname']); - $this->addElement('static', 'confirm_admin_firstname', get_lang("AdminFirstName"), $values['admin_firstname']); - $this->addElement('static', 'confirm_admin_phone', get_lang("AdminPhone"), $values['admin_phone']); - $this->addElement('static', 'confirm_admin_username', get_lang("AdminLogin"), $values['admin_username']); - $this->addElement('static', 'confirm_admin_password', get_lang("AdminPass"), $values['admin_password']); - $this->addElement('static', 'confirm_platform_name', get_lang("CampusName"), $values['platform_name']); - $this->addElement('static', 'confirm_organization_name', get_lang("InstituteShortName"), $values['organization_name']); - $this->addElement('static', 'confirm_organization_url', get_lang("InstituteURL"), $values['organization_url']); - $prevnext[] = & $this->createElement('submit', $this->getButtonName('back'), '<< '.get_lang('Previous')); - $prevnext[] = & $this->createElement('submit', $this->getButtonName('next'), get_lang('Next').' >>'); - $this->addGroup($prevnext, 'buttons', '', ' ', false); - $this->setDefaultAction('next'); - } -} - - -/** - * Class to render a page in the install wizard. - */ -class ActionDisplay extends HTML_QuickForm_Action_Display { - - /** - * Displays the HTML-code of a page in the wizard - * @param HTML_Quickform_Page $page The page to display. - */ - function _renderForm(& $current_page) { - global $charset; - - global $dokeos_version, $installType, $updateFromVersion; - $renderer = & $current_page->defaultRenderer(); - $current_page->setRequiredNote('* '.get_lang('ThisFieldIsRequired')); - $element_template = "\n\t\n\t\t* {label}\n\t\t{error}
    \t{element}\n\t"; - $renderer->setElementTemplate($element_template); - $header_template = "\n\t\n\t\t{header}\n\t"; - $renderer->setHeaderTemplate($header_template); - HTML_QuickForm :: setRequiredNote('* '.get_lang('ThisFieldIsRequired').''); - $current_page->accept($renderer); -?> - - - - -- Dokeos - upgrade to version <?php echo $dokeos_version; ?> - - - - -
    - Dokeos - upgrade to version -
    -
    - logo - controller->_pages; - $total_number_of_pages = count($all_pages); - $current_page_number = 0; - $page_number = 0; - echo '
      '; - foreach($all_pages as $index => $page) { - $page_number++; - if ($page->get_title() == $current_page->get_title()) { - $current_page_number = $page_number; - echo '
    1. '.$page->get_title().'
    2. '; - } else { - echo '
    3. '.$page->get_title().'
    4. '; - } - } - echo '
    '; - echo '
    '; - echo '
    '; - echo '

    '.get_lang('Step').' '.$current_page_number.' '.get_lang('of').' '.$total_number_of_pages.' – '.$current_page->get_title().'

    '; - echo '
    '; - echo $current_page->get_info(); - echo '
    '; - echo $renderer->toHtml(); - ?> -
    -
    - - - - controller->exportValues(); - ?> - - - - -- Dokeos installation -- version <?php echo $dokeos_version; ?> - - - - -
    - Dokeos installation - version -
    -
    - logo - '; - - global $repository_database; - global $weblcms_database; - global $personal_calendar_database; - global $user_database; - global $personal_messenger_database; - global $profiler_database; - - $repository_database = $values['database_repository']; - $weblcms_database = $values['database_weblcms']; - $personal_calendar_database = $values['database_personal_calendar']; - $user_database = $values['database_user']; - $personal_messenger_database = $values['database_personal_messenger']; - $profiler_database = $values['database_profiler']; - - /*full_database_install($values); - full_file_install($values); - create_admin_in_user_table($values); - create_default_categories_in_weblcms();*/ - echo "

    Performing upgrade to latest version....

    "; - - //upgrade_16x_to_180($values); - - echo ''; - $page->controller->container(true); - ?> - -
    - - - - - - - — <?php echo get_lang('DokeosInstallation').' — '.get_lang('Version_').' '.$dokeos_version; ?> - - - - - - - - - '; - echo 'Dokeos logo'; - echo '
      '; - echo '
    1. ' . get_lang('InstallationLanguage') . '
    2. '; - echo '
    3. ' . get_lang('Requirements') . '
    4. '; - echo '
    5. ' . get_lang('Licence') . '
    6. '; - echo '
    7. ' . get_lang('DBSetting') . '
    8. '; - echo '
    9. ' . get_lang('CfgSetting') . '
    10. '; - echo '
    11. ' . get_lang('PrintOverview') . '
    12. '; - echo '
    13. ' . get_lang('Installing') . '
    14. '; - echo '
    '; - echo ''; -} - -/** - * This function prints class=active_step $current_step=$param - * @author Patrick Cool , Ghent University - */ -function step_active($this_step) { - global $current_active_step; - if ($current_active_step == $this_step) { - return ' class="current_step" '; - } -} - -// Rule to check update path -function check_update_path($path) { - global $update_from_version; - // Make sure path has a trailing / - $path = substr($path, -1) != '/' ? $path.'/' : $path; - // Check the path - if (file_exists($path)) { - //search for 1.6.x installation - $version = get_installed_version($path, 'platformVersion'); - - //search for 1.8.x installation - //if (! isset($version) || $version == '') { - // $version = get_installed_version($path, 'dokeos_version'); - //} - - if (in_array($version, $update_from_version)) { - return true; - } else { - return false; - } - } - return false; -} - -/** - * This function returns the installed version of - * the older installation to upgrade by checking the - * claroline/inc/installedVersion.inc.php file. - */ -function get_installed_version($old_installation_path, $parameter) { - if (file_exists($old_installation_path.'claroline/inc/installedVersion.inc.php')) { - $version_info_file = 'claroline/inc/installedVersion.inc.php'; - } - // with include_once inside a function, variables aren't remembered for later use - include($old_installation_path.$version_info_file); - if (isset($$parameter)) { - return $$parameter; - } -} - -/** - * This function returns a the value of a parameter from the configuration file - * of a previous installation. - * - * IMPORTANT - * - Before Dokeos 1.8 the main code folder was called 'claroline'. Since Dokeos 1.8 - * this folder is called 'main' -> we have to make a difference based on previous - * version. - * - The version may be in the config file or in the installedVersion file... - * - * WARNING - this function relies heavily on global variables $updateFromConfigFile - * and $configFile, and also changes these globals. This can be rewritten. - * - * @param string $param the parameter which the value is returned for - * @return string the value of the parameter - * @author Olivier Brouckaert - */ -function get_config_param($param, $path) { - global $configFile, $updateFromConfigFile; - - if (empty($updateFromConfigFile)) { - if (file_exists($path.'claroline/include/config.inc.php')) { - $updateFromConfigFile = 'claroline/include/config.inc.php'; - } elseif (file_exists($path.'claroline/inc/conf/claro_main.conf.php')) { - $updateFromConfigFile = 'claroline/inc/conf/claro_main.conf.php'; - } else { - return; - } - } - - //echo "reading from file $path$updateFromConfigFile, which exists..."; - - if (is_array($configFile) && isset($configFile[$param])) { - return $configFile[$param]; - } elseif (file_exists($path.$updateFromConfigFile)) { - $configFile = array(); - - $temp = file($path.$updateFromConfigFile); - $val = ''; - foreach ($temp as $enreg) { - - if (strstr($enreg, '=')) { - $enreg = explode('=', $enreg); - - if ($enreg[0][0] == '$') { - list ($enreg[1]) = explode(' //', $enreg[1]); - - $enreg[0] = trim(str_replace('$', '', $enreg[0])); - $enreg[1] = str_replace('\"', '"', preg_replace('/^"|"$/', '', substr(trim($enreg[1]), 0, -1))); - - if (strtolower($enreg[1]) == 'true') { - $enreg[1] = 1; - } - if (strtolower($enreg[1]) == 'false') { - $enreg[1] = 0; - } else { - $implode_string = ' '; - - if (!strstr($enreg[1], '." ".') && strstr($enreg[1], '.$')) { - $enreg[1] = str_replace('.$', '." ".$', $enreg[1]); - $implode_string = ''; - } - - $tmp = explode('." ".', $enreg[1]); - - foreach ($tmp as $tmp_key => $tmp_val) { - if (preg_match('/^\$[a-zA-Z_][a-zA-Z0-9_]*$/', $tmp_val)) { - $tmp[$tmp_key] = get_config_param(str_replace('$', '', $tmp_val), $path); - } - } - - $enreg[1] = implode($implode_string, $tmp); - } - - $configFile[$enreg[0]] = $enreg[1]; - - if ($enreg[0] == $param) { - $val = $enreg[1]; - } - } - } - } - - return $val; - } -} - -/* -============================================================================== - MAIN CODE -============================================================================== -*/ -global $current_active_step; -$current_active_step = '1'; -$install_type = 'update'; -//display_upgrade_header($text_dir, $dokeos_version, $install_type, $update_from_version); -//display_installation_overview(); - -// Create a new wizard -$wizard = & new HTML_QuickForm_Controller('regWizard', true); - -//Add pages to wizard - path to follow for upgrade -//$wizard->addPage(new Page_Language('page_language')); -//$wizard->addPage(new Page_Requirements('page_requirements')); -$wizard->addPage(new Page_LocationOldVersion('page_location_old_version')); -$values = $wizard->exportValues(); - -if (isset($values['old_version_path']) && $values['old_version_path'] != '/var/www/html/old_version/') { - $path = $values['old_version_path']; - $defaults['platform_language'] = get_config_param('platformLanguage',$path); - $defaults['platform_url'] = 'http://'.$_SERVER['HTTP_HOST'].$urlAppendPath.'/'; - //to keep debug output readable: - //$defaults['license'] = 'GNU GPL v2'; - //actual license: - $defaults['license'] = implode("\n", file('../../documentation/license.txt')); - $defaults['database_host'] = get_config_param('dbHost',$path); - $defaults['database_main_db'] = get_config_param('mainDbName',$path); - $defaults['database_tracking'] = get_config_param('statsDbName',$path); - $defaults['database_scorm'] = get_config_param('scormDbName',$path); - $defaults['database_user'] = get_config_param('user_personal_database',$path); - //$defaults['database_repository'] = 'dokeos_repository'; - //$defaults['database_weblcms'] = 'dokeos_weblcms'; - $defaults['database_username'] = get_config_param('dbLogin',$path); - $defaults['database_password'] = get_config_param('dbPass',$path); - $defaults['database_prefix'] = get_config_param('dbNamePrefix',$path); - $defaults['enable_tracking'] = get_config_param('is_trackingEnabled',$path); - $defaults['database_single'] = get_config_param('singleDbEnabled',$path); - $defaults['admin_lastname'] = 'Doe'; - $defaults['admin_firstname'] = mt_rand(0,1)?'John':'Jane'; - $defaults['admin_email'] = get_config_param('emailAdministrator',$path); - $defaults['admin_username'] = 'admin'; - $defaults['admin_password'] = api_generate_password(); - $defaults['admin_phone'] = get_config_param('administrator["phone"]',$path); - $defaults['platform_name'] = get_config_param('siteName',$path); - $defaults['encrypt_password'] = 1; - $defaults['organization_name'] = get_config_param('institution["name"]',$path); - $defaults['organization_url'] = get_config_param('institution["url"]',$path); - if (get_config_param('userPasswordCrypted',$path)==1) { - $defaults['encrypt_password'] = 'md5'; - } elseif (get_config_param('userPasswordCrypted',$path)==0){ - $defaults['encrypt_password'] = 'none'; - } - //$defaults['encrypt_password'] = get_config_param('userPasswordCrypted',$path); - $defaults['self_reg'] = get_config_param('allowSelfReg',$path); -} else { - //old version path not correct yet -} - -$wizard->addPage(new Page_License('page_license')); -$wizard->addPage(new Page_DatabaseSettings('page_databasesettings')); -$wizard->addPage(new Page_ConfigSettings('page_configsettings')); -$wizard->addPage(new Page_ConfirmSettings('page_confirmsettings')); - -$defaults['install_language'] = 'english'; -//$defaults['old_version_path'] = '/var/www/html/old_version/'; -$defaults['old_version_path'] = ''; - -// Set the default values -$wizard->setDefaults($defaults); - -// Add the process action to the wizard -$wizard->addAction('process', new ActionProcess()); - -// Add the display action to the wizard -$wizard->addAction('display', new ActionDisplay()); - -// Set the installation language -$install_language = $wizard->exportValue('page_language', 'install_language'); -require_once '../lang/english/trad4all.inc.php'; -require_once '../lang/english/install.inc.php'; -include_once '../lang/'.$install_language.'/trad4all.inc.php'; -include_once '../lang/'.$install_language.'/install.inc.php'; - -// Set default platform language to the selected install language -$defaults['platform_language'] = $install_language; -$wizard->setDefaults($defaults); - -// Start the wizard -$wizard->run(); - -// Set the installation language -$install_language = $wizard->exportValue('page_language', 'install_language'); -require_once '../lang/english/trad4all.inc.php'; -require_once '../lang/english/install.inc.php'; -include_once '../lang/'.$install_language.'/trad4all.inc.php'); -include_once '../lang/'.$install_language.'/install.inc.php'); - -//$values = $wizard->exportValues(); diff --git a/main/install/_upgrade_lib.php b/main/install/_upgrade_lib.php deleted file mode 100644 index d8d207de4b..0000000000 --- a/main/install/_upgrade_lib.php +++ /dev/null @@ -1,181 +0,0 @@ - 0) { - Database::select_db($main_database); - foreach ($main_query_list as $this_query) { - Database::query($this_query); - } - } - - //TRACKING database section - //Get the list of queries to upgrade the statistics/tracking database - $tracking_query_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-pre.sql', 'stats'); - if (count($tracking_query_list) > 0) { - Database::select_db($tracking_database); - foreach ($tracking_query_list as $this_query) { - Database::query($this_query); - } - } - - //USER database section - //Get the list of queries to upgrade the user database - $user_query_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-pre.sql', 'user'); - if (count($user_query_list) > 0) { - Database::select_db($user_database); - foreach ($user_query_list as $this_query) { - Database::query($this_query); - } - } - - /* - COURSE SECTION - UPGRADES TO COURSE DATABASES - */ - $prefix = ''; - global $singleDbForm, $_configuration; - if ($singleDbForm) { - $prefix = $_configuration['table_prefix']; - } - //get the course databases queries list (c_q_list) - $course_query_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-pre.sql', 'course'); - if (count($course_query_list) > 0) { - //upgrade course databases - } - - /* - SCORM SECTION - */ - //see include('update-db-scorm-1.6.x-1.8.0.inc.php'); - //deploy in separate function! - - /* - POST SECTION - UPGRADES TO GENERAL DATABASES after course upgrades - */ - $main_query_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-post.sql', 'main'); - if (count($main_query_list) > 0) { - Database::select_db($main_database); - foreach ($main_query_list as $this_query) { - Database::query($this_query); - } - } - - $tracking_query_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-post.sql', 'stats'); - $tracking_query_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-pre.sql', 'stats'); - if (count($tracking_query_list) > 0) { - Database::select_db($tracking_database); - foreach ($tracking_query_list as $this_query) { - Database::query($this_query); - } - } - - $user_query_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-post.sql', 'user'); - if (count($user_query_list) > 0) { - Database::select_db($user_database); - foreach ($user_query_list as $this_query) { - Database::query($this_query); - } - } - - $prefix = ''; - if ($singleDbForm) { - $prefix = $_configuration['table_prefix']; - } - //get the course databases queries list (c_q_list) - $course_query_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-pre.sql', 'course'); - if (count($course_query_list) > 0) { - //upgrade course databases - Database::select_db($main_database); - $sql_result = Database::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL"); - if (Database::num_rows($sql_result) > 0) { - while ($row = Database::fetch_array($sql_result)) { - $course_list[] = $row; - } - //for each course in the course list... - foreach ($course_list as $this_course) { - Database::select_db($this_course['db_name']); - //... execute the list of course update queries - foreach ($course_query_list as $this_query) { - if ($is_single_database) { //otherwise just use the main one - $query = preg_replace('/^(UPDATE|ALTER TABLE|CREATE TABLE|DROP TABLE|INSERT INTO|DELETE FROM)\s+(\w*)(.*)$/', "$1 $prefix$2$3", $query); - } - Database::query($this_query); - } - } - } - } -} - -/** -* Note - there is no 1.8.1, -* 1.8.2 is the version that came after 1.8.0 -* see -* - update-db-1.8.0-1.8.2.inc.php -* - migrate-db-1.8.0-1.8.2-pre.sql -*/ -function upgrade_180_to_182($values) { - -} - -function upgrade_182_to_183($values) { - //no database/file structure changes needed? -}