Task #836 Instalaltion scripts: System paths are used on treating files inside the system.

skala
Ivan Tcholakov 16 years ago
parent 4689cca36f
commit 5f05dd3290
  1. 83
      main/install/install.lib.php
  2. 12
      main/install/install_files.inc.php
  3. 6
      main/install/update-db-scorm-1.6.x-1.8.0.inc.php
  4. 4
      main/install/update-files-1.6.x-1.8.0.inc.php
  5. 10
      main/install/update-files-1.8.3-1.8.4.inc.php
  6. 10
      main/install/update-files-1.8.4-1.8.5.inc.php
  7. 12
      main/install/update-files-1.8.5-1.8.6.inc.php
  8. 12
      main/install/update-files-1.8.6-1.8.6.1.inc.php
  9. 12
      main/install/update-files-1.8.6.1-1.8.6.2.inc.php
  10. 4
      main/install/update-files-1.8.6.2-1.8.7.inc.php

@ -33,12 +33,12 @@ function is_already_installed_system() {
return true; // Must be initialized.
}
$current_config_file = str_replace('\\', '/', realpath('../inc/conf/configuration.php'));
$current_config_file = api_get_path(CONFIGURATION_PATH).'configuration.php';
if (!file_exists($current_config_file)) {
return false; // Configuration file does not exist, install the system.
}
require $current_config_file;
$current_version = trim($_configuration['dokeos_version']);
if (empty($current_version)) {
$current_version = trim($_configuration['system_version']);
@ -213,7 +213,7 @@ function detect_browser_language() {
* This function checks if the given folder is writable
*/
function check_writable($folder, $suggestion = false) {
if (is_writable('../'.$folder)) {
if (is_writable(api_get_path(SYS_CODE_PATH).$folder)) {
return '<strong><font color="green">'.get_lang('Writable').'</font></strong>';
} else {
if ($suggestion) {
@ -251,10 +251,9 @@ function set_file_folder_permissions() {
* @param string $url_append The path from your webroot to your chamilo root
*/
function write_courses_htaccess_file($url_append) {
$file_path = dirname(__FILE__).'/'.COURSES_HTACCESS_FILENAME;
$content = file_get_contents($file_path);
$content = file_get_contents(dirname(__FILE__).'/'.COURSES_HTACCESS_FILENAME);
$content = str_replace('{CHAMILO_URL_APPEND_PATH}', $url_append, $content);
$fp = @ fopen('../../courses/.htaccess', 'w');
$fp = @ fopen(api_get_path(SYS_PATH).'courses/.htaccess', 'w');
if ($fp) {
fwrite($fp, $content);
return fclose($fp);
@ -1173,11 +1172,11 @@ function display_requirements($installType, $badUpdatePath, $updatePath = '', $u
</tr>
<tr>
<td class="requirements-item">chamilo/main/css/</td>
<td class="requirements-value">'.check_writable('css/',true).' ('.get_lang('SuggestionOnlyToEnableCSSUploadFeature').')</td>
<td class="requirements-value">'.check_writable('css/', true).' ('.get_lang('SuggestionOnlyToEnableCSSUploadFeature').')</td>
</tr>
<tr>
<td class="requirements-item">chamilo/main/lang/</td>
<td class="requirements-value">'.check_writable('lang/',true).' ('.get_lang('SuggestionOnlyToEnableSubLanguageFeature').')</td>
<td class="requirements-value">'.check_writable('lang/', true).' ('.get_lang('SuggestionOnlyToEnableSubLanguageFeature').')</td>
</tr>'.
//'<tr>
// <td class="requirements-item">chamilo/searchdb/</td>
@ -1231,43 +1230,51 @@ function display_requirements($installType, $badUpdatePath, $updatePath = '', $u
$notwritable = array();
$curdir = getcwd();
if (!is_writable('../inc/conf')) {
$notwritable[] = realpath($curdir.'/../inc/conf');
@chmod('../inc/conf',$perm);
$checked_writable = api_get_path(CONFIGURATION_PATH);
if (!is_writable($checked_writable)) {
$notwritable[] = $checked_writable;
@chmod($checked_writable, $perm);
}
if (!is_writable('../upload/users')) {
$notwritable[] = realpath($curdir.'/../upload/users');
@chmod('../upload/users', $perm);
$checked_writable = api_get_path(SYS_CODE_PATH).'upload/users/';
if (!is_writable($checked_writable)) {
$notwritable[] = $checked_writable;
@chmod($checked_writable, $perm);
}
if (!is_writable('../default_course_document/images/')) {
$notwritable[] = realpath($curdir.'/../default_course_document/images/');
@chmod('../default_course_document/images/', $perm);
$checked_writable = api_get_path(SYS_CODE_PATH).'default_course_document/images/';
if (!is_writable($checked_writable)) {
$notwritable[] = $checked_writable;
@chmod($checked_writable, $perm);
}
if (!is_writable('../../archive')) {
$notwritable[] = realpath($curdir.'/../../archive');
@chmod('../../archive',$perm);
$checked_writable = api_get_path(SYS_ARCHIVE_PATH);
if (!is_writable($checked_writable)) {
$notwritable[] = $checked_writable;
@chmod($checked_writable, $perm);
}
if (!is_writable('../../courses')) {
$notwritable[] = realpath($curdir.'/../../courses');
@chmod('../../courses',$perm);
$checked_writable = api_get_path(SYS_COURSE_PATH);
if (!is_writable($checked_writable)) {
$notwritable[] = $checked_writable;
@chmod($checked_writable, $perm);
}
if (!is_writable('../../home')) {
$notwritable[] = realpath($curdir.'/../../home');
@chmod('../../home',$perm);
$checked_writable = api_get_path(SYS_PATH).'home/';
if (!is_writable($checked_writable)) {
$notwritable[] = realpath($checked_writable);
@chmod($checked_writable, $perm);
}
if (file_exists('../inc/conf/configuration.php') && !is_writable('../inc/conf/configuration.php')) {
$notwritable[]= realpath($curdir.'/../inc/conf/configuration.php');
@chmod('../inc/conf/configuration.php',$perm_file);
$checked_writable = api_get_path(CONFIGURATION_PATH).'configuration.php';
if (file_exists($checked_writable) && !is_writable($checked_writable)) {
$notwritable[] = $checked_writable;
@chmod($checked_writable, $perm_file);
}
//Second, if this fails, report an error
//--> the user will have to adjust the permissions manually
// Second, if this fails, report an error
//--> The user would have to adjust the permissions manually
if (count($notwritable) > 0) {
$error = true;
echo '<div style="color:red; background-color:white; font-weight:bold; text-align:center;">';
@ -1281,24 +1288,24 @@ function display_requirements($installType, $badUpdatePath, $updatePath = '', $u
echo '</div>';
}
// check wether a Chamilo configuration file already exists.
elseif (file_exists('../inc/conf/configuration.php')) {
// Check wether a Chamilo configuration file already exists.
elseif (file_exists(api_get_path(CONFIGURATION_PATH).'configuration.php')) {
echo '<div style="color:red; background-color:white; font-weight:bold; text-align:center;">';
echo get_lang('WarningExistingDokeosInstallationDetected');
echo '</div>';
}
//and now display the choice buttons (go back or install)
// And now display the choice buttons (go back or install)
?>
<p align="center">
<button type="submit" name="step1" class="back" onclick="javascript: window.location='index.php'; return false;" value="&lt; <?php echo get_lang('Previous'); ?>" ><?php echo get_lang('Previous'); ?></button>
<button type="submit" name="step2_install" class="add" value="<?php echo get_lang("NewInstallation"); ?>" <?php if ($error) echo 'disabled="disabled"'; ?> ><?php echo get_lang('NewInstallation'); ?></button>
<input type="hidden" name="is_executable" id="is_executable" value="-" />
<?php
//real code
// Real code
echo '<button type="submit" class="save" name="step2_update_8" value="Upgrade from Dokeos 1.8.x"';
if ($error) echo ' disabled="disabled"';
//temporary code for alpha version, disabling upgrade
// Temporary code for alpha version, disabling upgrade
//echo '<input type="submit" name="step2_update" value="Upgrading is not possible in this beta version"';
//echo ' disabled="disabled"';
//end temp code
@ -1322,12 +1329,12 @@ function display_license_agreement() {
?>
<table>
<tr><td>
<p style="font-size:75%"><textarea cols="80" rows="15" ><?php htmlentities(include('../../documentation/license.txt')); ?></textarea></p>
<p style="font-size:75%"><textarea cols="80" rows="15" ><?php echo api_htmlentities(@file_get_contents(api_get_path(SYS_PATH).'documentation/license.txt')); ?></textarea></p>
</td>
</tr>
<tr>
<td>
<p><?php echo get_lang('DokeosArtLicense');?></p>
<p><?php echo get_lang('DokeosArtLicense'); ?></p>
</td>
</tr>
<td>

@ -17,19 +17,19 @@
if (defined('SYSTEM_INSTALLATION')) {
// Write the system config file
write_system_config_file('../inc/conf/configuration.php');
write_system_config_file(api_get_path(CONFIGURATION_PATH).'configuration.php');
// Write a distribution file with the config as a backup for the admin
write_system_config_file('../inc/conf/configuration.dist.php');
write_system_config_file(api_get_path(CONFIGURATION_PATH).'configuration.dist.php');
// Write a .htaccess file in the course repository
write_courses_htaccess_file($urlAppendPath);
// Copy distribution files with renaming for being the actual system configuration files.
copy('../inc/conf/add_course.conf.dist.php', '../inc/conf/add_course.conf.php');
copy('../inc/conf/course_info.conf.dist.php', '../inc/conf/course_info.conf.php');
copy('../inc/conf/mail.conf.dist.php', '../inc/conf/mail.conf.php');
copy('../inc/conf/profile.conf.dist.php', '../inc/conf/profile.conf.php');
copy(api_get_path(CONFIGURATION_PATH).'add_course.conf.dist.php', api_get_path(CONFIGURATION_PATH).'add_course.conf.php');
copy(api_get_path(CONFIGURATION_PATH).'course_info.conf.dist.php', api_get_path(CONFIGURATION_PATH).'course_info.conf.php');
copy(api_get_path(CONFIGURATION_PATH).'mail.conf.dist.php', api_get_path(CONFIGURATION_PATH).'mail.conf.php');
copy(api_get_path(CONFIGURATION_PATH).'profile.conf.dist.php', api_get_path(CONFIGURATION_PATH).'profile.conf.php');
} else {

@ -37,9 +37,9 @@ function my_get_time($time) {
}
// Open log file
$fh = fopen('../../archive/newscorm_'.time().'.log', 'w');
$fh_revert = fopen('../../archive/newscorm_'.time().'_revert.log', 'w');
$fh_res = fopen('../../archive/newscorm_'.time().'_res.log', 'w');
$fh = fopen(api_get_path(SYS_ARCHIVE_PATH).'newscorm_'.time().'.log', 'w');
$fh_revert = fopen(api_get_path(SYS_ARCHIVE_PATH).'newscorm_'.time().'_revert.log', 'w');
$fh_res = fopen(api_get_path(SYS_ARCHIVE_PATH)'newscorm_'.time().'_res.log', 'w');
fwrite($fh, "-- Recording course homepages links changes to enable reverting\n");
fwrite($fh_revert, "-- Recording reverted course homepages links changes to enable reverting\n");
fwrite($fh_res, "-- Recording resulting course homepages links changes\n");

@ -125,9 +125,9 @@ if (defined('SYSTEM_INSTALLATION')) {
}
// Write the config file
write_system_config_file('../inc/conf/configuration.php');
write_system_config_file(api_get_path(CONFIGURATION_PATH).'configuration.php');
// Write a distribution file with the config as a backup for the admin
write_system_config_file('../inc/conf/configuration.dist.php');
write_system_config_file(api_get_path(CONFIGURATION_PATH).'configuration.dist.php');
// Write a .htaccess file in the course repository
write_courses_htaccess_file($urlAppendPath);
copy($updatePath.'claroline/inc/conf/add_course.conf.php', $pathForm.'main/inc/conf/add_course.conf.php');

@ -20,19 +20,19 @@
if (defined('SYSTEM_INSTALLATION')) {
// Edit the configuration file
$file = file('../inc/conf/configuration.php');
$fh = fopen('../inc/conf/configuration.php', 'w');
$file = file(api_get_path(CONFIGURATION_PATH).'configuration.php');
$fh = fopen(api_get_path(CONFIGURATION_PATH).'configuration.php', 'w');
$found_version = false;
$found_stable = false;
foreach ($file as $line) {
$ignore = false;
if (stristr($line, '$_configuration[\'dokeos_version\']')) {
if (stripos($line, '$_configuration[\'dokeos_version\']') !== false) {
$found_version = true;
$line = '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n";
} elseif (stristr($line, '$_configuration[\'dokeos_stable\']')) {
} elseif (stripos($line, '$_configuration[\'dokeos_stable\']') !== false) {
$found_stable = true;
$line = '$_configuration[\'dokeos_stable\'] = '.($new_version_stable ? 'true' : 'false').';'."\r\n";
} elseif (stristr($line, '?>')) {
} elseif (stripos($line, '?>') !== false) {
// Ignore the line
$ignore = true;
}

@ -20,19 +20,19 @@
if (defined('SYSTEM_INSTALLATION')) {
// Edit the configuration file
$file = file('../inc/conf/configuration.php');
$fh = fopen('../inc/conf/configuration.php', 'w');
$file = file(api_get_path(CONFIGURATION_PATH).'configuration.php');
$fh = fopen(api_get_path(CONFIGURATION_PATH).'configuration.php', 'w');
$found_version = false;
$found_stable = false;
foreach ($file as $line) {
$ignore = false;
if (stristr($line, '$_configuration[\'dokeos_version\']')) {
if (stripos($line, '$_configuration[\'dokeos_version\']') !== false) {
$found_version = true;
$line = '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n";
} elseif (stristr($line, '$_configuration[\'dokeos_stable\']')) {
} elseif (stripos($line, '$_configuration[\'dokeos_stable\']') !== false) {
$found_stable = true;
$line = '$_configuration[\'dokeos_stable\'] = '.($new_version_stable ? 'true' : 'false').';'."\r\n";
} elseif (stristr($line, '?>')) {
} elseif (stripos($line, '?>') !== false) {
// Ignore the line
$ignore = true;
}

@ -20,21 +20,21 @@
if (defined('SYSTEM_INSTALLATION')) {
// Edit the configuration file
$file = file('../inc/conf/configuration.php');
$fh = fopen('../inc/conf/configuration.php', 'w');
$file = file(api_get_path(CONFIGURATION_PATH).'configuration.php');
$fh = fopen(api_get_path(CONFIGURATION_PATH).'configuration.php', 'w');
$found_version = false;
$found_stable = false;
foreach ($file as $line) {
$ignore = false;
if (stristr($line, '$_configuration[\'dokeos_version\']')) {
if (stripos($line, '$_configuration[\'dokeos_version\']') !== false) {
$found_version = true;
$line = '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n";
} elseif (stristr($line, '$_configuration[\'dokeos_stable\']')) {
} elseif (stripos($line, '$_configuration[\'dokeos_stable\']') !== false) {
$found_stable = true;
$line = '$_configuration[\'dokeos_stable\'] = '.($new_version_stable ? 'true' : 'false').';'."\r\n";
} elseif (stristr($line,'$userPasswordCrypted')) {
} elseif (stripos($line,'$userPasswordCrypted') !== false) {
$line = '$userPasswordCrypted = \''.($userPasswordCrypted).'\';'."\r\n";
} elseif (stristr($line, '?>')) {
} elseif (stripos($line, '?>') !== false) {
// Ignore the line
$ignore = true;
}

@ -20,21 +20,21 @@
if (defined('SYSTEM_INSTALLATION')) {
// Edit the configuration file
$file = file('../inc/conf/configuration.php');
$fh = fopen('../inc/conf/configuration.php', 'w');
$file = file(api_get_path(CONFIGURATION_PATH).'configuration.php');
$fh = fopen(api_get_path(CONFIGURATION_PATH).'configuration.php', 'w');
$found_version = false;
$found_stable = false;
foreach ($file as $line) {
$ignore = false;
if (stristr($line, '$_configuration[\'dokeos_version\']')) {
if (stripos($line, '$_configuration[\'dokeos_version\']') !== false) {
$found_version = true;
$line = '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n";
} elseif (stristr($line, '$_configuration[\'dokeos_stable\']')) {
} elseif (stripos($line, '$_configuration[\'dokeos_stable\']') !== false) {
$found_stable = true;
$line = '$_configuration[\'dokeos_stable\'] = '.($new_version_stable ? 'true' : 'false').';'."\r\n";
} elseif (stristr($line, '$userPasswordCrypted')) {
} elseif (stripos($line, '$userPasswordCrypted') !== false) {
$line = '$userPasswordCrypted = \''.($userPasswordCrypted).'\';'."\r\n";
} elseif (stristr($line, '?>')) {
} elseif (stripos($line, '?>') !== false) {
//ignore the line
$ignore = true;
}

@ -14,21 +14,21 @@
if (defined('SYSTEM_INSTALLATION')) {
// Edit the configuration file
$file = file('../inc/conf/configuration.php');
$fh = fopen('../inc/conf/configuration.php', 'w');
$file = file(api_get_path(CONFIGURATION_PATH).'configuration.php');
$fh = fopen(api_get_path(CONFIGURATION_PATH).'configuration.php', 'w');
$found_version = false;
$found_stable = false;
foreach ($file as $line) {
$ignore = false;
if (stristr($line, '$_configuration[\'dokeos_version\']')) {
if (stripos($line, '$_configuration[\'dokeos_version\']') !== false) {
$found_version = true;
$line = '$_configuration[\'dokeos_version\'] = \''.$new_version.'\';'."\r\n";
} elseif(stristr($line, '$_configuration[\'dokeos_stable\']')) {
} elseif (stripos($line, '$_configuration[\'dokeos_stable\']') !== false) {
$found_stable = true;
$line = '$_configuration[\'dokeos_stable\'] = '.($new_version_stable?'true':'false').';'."\r\n";
} elseif(stristr($line,'$userPasswordCrypted')) {
} elseif (stripos($line,'$userPasswordCrypted') !== false) {
$line = '$userPasswordCrypted = \''.($userPasswordCrypted).'\';'."\r\n";
} elseif(stristr($line, '?>')) {
} elseif (stripos($line, '?>') !== false) {
//ignore the line
$ignore = true;
}

@ -14,8 +14,8 @@
if (defined('SYSTEM_INSTALLATION')) {
// Edit the configuration file
$file = file('../inc/conf/configuration.php');
$fh = fopen('../inc/conf/configuration.php', 'w');
$file = file(api_get_path(CONFIGURATION_PATH).'configuration.php');
$fh = fopen(api_get_path(CONFIGURATION_PATH).'configuration.php', 'w');
$found_version_old = false;
$found_stable_old = false;
$found_version = false;

Loading…
Cancel
Save