<?php
/****************************************************************************************/
/* ACollab */
/****************************************************************************************/
/* Copyright (c) 2002-2005 Adaptive Technology Resource Centre / University of Toronto */
/* */
/* http://atutor.ca/acollab */
/* */
/* This program is free software. You may redistribute it and/or */
/* modify it under the terms of the GNU General Public License */
/* as published by the Free Software Foundation; either version 2 of the License, */
/* or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, but */
/* WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */
/* See the GNU General Public License for more details. */
/* */
/* You may access the GNU General Public License at: */
/* http://www.opensource.org/licenses/gpl-license.php */
/* */
/* You may contact the Adaptive Technology Resource Centre at */
/* Robarts Library, University of Toronto */
/* 130 St. George Street, Toronto, Ontario, Canada M5S 1A5 */
/* Further contact information is available at http://www.utoronto.ca/atrc/ */
/****************************************************************************************/
/* Programmer: */
/* Joel Kronenberg - ATRC */
/****************************************************************************************/
// $Id: ustep4.php 455 2005-03-08 19:35:40Z shozubq $
if (!defined('AC_INCLUDE_PATH')) { exit; }
require('../include/lib/filemanager.inc.php');
print_progress($step);
unset($errors);
$writeable = array('chat/', 'chat/msgs/', 'chat/users/', 'chat/tran/', 'chat/admin.settings', 'include/config.inc.php', $_POST['step3']['upload_dir']);
foreach ($writeable as $file) {
if (!is_dir('../'.$file)) {
if ( file_exists('../'.$file) ) {
@chmod('../'.$file, 0666);
if (!is_writeable('../'.$file)) {
$errors[] = '<b>'.$file . '</b> is not writeable.';
}else{
$progress[] = '<b>'.$file.'</b> is writeable.';
}
}
} else {
@chmod('../'.$file, 0777);
if (!is_writeable('../'.$file)) {
$errors[] = '<b>'.$file . '</b> is not writeable.';
}else{
$progress[] = '<b>'.$file.'</b> is writeable.';
}
}
}
echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post" name="form">';
if (isset($errors)) {
if (isset($progress)) {
print_feedback($progress);
}
print_errors($errors);
echo'<input type="hidden" name="step" value="'.$step.'" />';
unset($_POST['step']);
unset($_POST['action']);
print_hidden($step);
echo '<p><strong>Note:</strong> To change permissions on Unix use <kbd>chmod a+rwx</kbd> then the file or directory name.</p>';
echo '<p align="center"><input type="submit" class="button" value=" Try Again " name="retry" />';
} else {
echo '<input type="hidden" name="step" value="'.($step+1).'" />';
unset($_POST['step']);
unset($_POST['action']);
print_hidden($step);
require('include/config_template.php');
$comments = '/*'.str_pad(' This file was generated by the ACollab '.$new_version. ' installation script.', 70, ' ').'*/
/*'.str_pad(' File generated '.date('Y-m-d H:m:i'), 70, ' ').'*/';
write_config_file('../include/config.inc.php', $comments);
$progress[] = 'Data has been saved successfully.';
@chmod('../include/config.inc.php', 0444);
/* if the new upload direcotry is different from the old directory
copy all the files from the old upload directory to the new upload directory */
$original_path = urldecode($_POST['step1']['upload_dir']);
$new_path = urldecode($_POST['step3']['upload_dir']);
if (is_dir($original_path)) {
if (realpath($original_path) != realpath($new_path)) {
if (substr($original_path, -1) != '/') {
$slash_old = '/';
}
if (substr($new_path, -1) != '/') {
$slash_new = '/';
}
$dirs = scandir($original_path);
foreach ($dirs as $dir) {
if (is_numeric($dir)) {
copys($original_path.$slash_old.$dir, $new_path.$slash_new.$dir);
if (is_dir($new_path.$slash_new.$dir)) {
$progress[] = 'Upload directory <b>'.$dir.'</b> copied successfully.';
} else {
$errors[] = 'Upload directory <b>'.$dir.'</b> <strong>NOT</strong> copied.';
}
}
}
}
}
if (is_dir('../../'.$_POST['step1']['old_path'].'/chat/')) {
/*transcripts & admin settings */
$groups = scandir('../../'.$_POST['step1']['old_path'].'/chat/tran/');
foreach ($groups as $group) {
if (is_numeric($group)) {
copys('../../'.$_POST['step1']['old_path'].'/chat/tran/'.$group, '../chat/tran/'.$group);
if (is_file('../../'.$_POST['step1']['old_path'].'/chat/'.$group.'.admin.settings')) {
copy('../../'.$_POST['step1']['old_path'].'/chat/'.$group.'.admin.settings', '../chat/'.$group.'.admin.settings');
}
}
}
/*messages*/
$groups = scandir('../../'.$_POST['step1']['old_path'].'/chat/msgs/');
foreach ($groups as $group) {
if (is_numeric($group)) {
copys('../../'.$_POST['step1']['old_path'].'/chat/msgs/'.$group, '../chat/msgs/'.$group);
}
}
/*users*/
copys('../../'.$_POST['step1']['old_path'].'/chat/users/', '../chat/users/');
$progress[] = 'Group chat directories and settings copied successfully.';
}
print_feedback($progress);
echo '<p align="center"><input type="submit" class="button" value=" Next ยป " name="submit" />';
}
?>
</form>