2 /************************************************************************/
4 /************************************************************************/
5 /* Copyright (c) 2002-2008 by Greg Gay, Joel Kronenberg, Heidi Hazelton */
8 /* This program is free software. You can redistribute it and/or */
9 /* modify it under the terms of the GNU General Public License */
10 /* as published by the Free Software Foundation. */
11 /************************************************************************/
14 if (!defined('AT_INCLUDE_PATH')) { exit; }
15 session_unset(); //clear session before using it
17 print_progress($step);
19 if (isset($_POST['submit']) && (trim($_POST['old_path']) != '')) {
20 if ((strpos($_POST['old_path'], '/') === false) && is_dir('../../'.$_POST['old_path'])) {
21 if ( file_exists('../../'.$_POST['old_path'] . '/include/config.inc.php') ) {
23 require('../../'.$_POST['old_path'] . '/include/lib/constants.inc.php');
24 if (!defined('VERSION')) {
25 $errors[] = 'Cannot detect version number. Only ATutor versions greater than 1.0 can be upgraded. Upgrade to 1.1 manually then try upgrading to the latest version again.';
27 $progress[] = 'Found ATutor version <kbd><b>'.VERSION . '</b></kbd> in path <kbd><b>'.$_POST['old_path'].'</b></kbd>.';
29 if (!version_compare(VERSION, $new_version, '<')) {
30 $errors[] = 'The version upgrading (<kbd><b>'.VERSION.'</b></kbd>) is not older than the new version (<kbd><b>'.$new_version.'</b></kbd>).';
34 $progress[] = 'Will be upgrading from version <kbd><b>'.VERSION.'</b></kbd> to version <kbd><b>'.$new_version.'</b></kbd>.';
35 print_feedback($progress);
37 require('../../'.$_POST['old_path'] . '/include/config.inc.php');
39 if (is_array($IllegalExtentions)) {
40 $IllegalExtentions = implode(',', $IllegalExtentions);
43 echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post" name="form">';
44 echo '<input type="hidden" name="step" value="2" />';
45 echo '<input type="hidden" name="old_path" value="'.$_POST['old_path'].'" />';
47 echo '<input type="hidden" name="db_login" value="'.urlencode(DB_USER).'" />';
48 echo '<input type="hidden" name="db_password" value="'.urlencode(DB_PASSWORD).'" />';
49 echo '<input type="hidden" name="db_host" value="'.DB_HOST.'" />';
50 if (defined('DB_PORT')) {
51 echo '<input type="hidden" name="db_port" value="'.DB_PORT.'" />';
53 echo '<input type="hidden" name="db_port" value="3306" />';
55 echo '<input type="hidden" name="db_name" value="'.DB_NAME.'" />';
57 if (defined('TABLE_PREFIX')) {
58 echo '<input type="hidden" name="tb_prefix" value="'.TABLE_PREFIX.'" />';
60 echo '<input type="hidden" name="tb_prefix" value="" />';
62 if (defined('SITE_NAME')) {
63 echo '<input type="hidden" name="site_name" value="'.urlencode(SITE_NAME).'" />';
65 echo '<input type="hidden" name="site_name" value="'.$_defaults['site_name'].'" />';
67 if (defined('HEADER_IMAGE')) {
68 echo '<input type="hidden" name="header_img" value="'.HEADER_IMAGE.'" />';
70 echo '<input type="hidden" name="header_img" value="'.$_defaults['header_img'].'" />';
72 if (defined('HEADER_LOGO')) {
73 echo '<input type="hidden" name="header_logo" value="'.HEADER_LOGO.'" />';
75 echo '<input type="hidden" name="header_logo" value="'.$_defaults['header_logo'].'" />';
77 if (defined('HOME_URL')) {
78 echo '<input type="hidden" name="home_url" value="'.HOME_URL.'" />';
80 echo '<input type="hidden" name="home_url" value="'.$_defaults['home_url'].'" />';
83 if (defined('MAIL_USE_SMTP')) {
84 echo '<input type="hidden" name="smtp" value="'.(MAIL_USE_SMTP ? 'TRUE' : 'FALSE').'" />';
86 echo '<input type="hidden" name="smtp" value="FALSE" />';
88 if (defined('AT_FORCE_GET_FILE')) {
89 echo '<input type="hidden" name="get_file" value="'.(AT_FORCE_GET_FILE ? 'TRUE' : 'FALSE').'" />';
91 echo '<input type="hidden" name="get_file" value="FALSE" />';
93 echo '<input type="hidden" name="admin_password" value="'.urlencode(ADMIN_PASSWORD).'" />';
95 if (defined('ADMIN_USERNAME')) {
96 echo '<input type="hidden" name="admin_username" value="'.ADMIN_USERNAME.'" />';
98 echo '<input type="hidden" name="admin_username" value="'.$_defaults['admin_username'].'" />';
101 if (defined('ADMIN_EMAIL')) {
102 echo '<input type="hidden" name="admin_email" value="'.ADMIN_EMAIL.'" />';
104 echo '<input type="hidden" name="admin_email" value="'.$_defaults['admin_email'].'" />';
106 if (defined('EMAIL')) {
107 echo '<input type="hidden" name="contact_email" value="'.EMAIL.'" />';
108 } else if (defined('ADMIN_EMAIL')) {
109 echo '<input type="hidden" name="contact_email" value="'.ADMIN_EMAIL.'" />';
111 echo '<input type="hidden" name="contact_email" value="'.$_defaults['admin_email'].'" />';
113 if (defined('EMAIL_NOTIFY')) {
114 echo '<input type="hidden" name="email_notification" value="'.(EMAIL_NOTIFY ? 'TRUE' : 'FALSE').'" />';
116 echo '<input type="hidden" name="email_notification" value="'.$_defaults['email_notification'].'" />';
118 if (defined('ALLOW_INSTRUCTOR_REQUESTS')) {
119 echo '<input type="hidden" name="allow_instructor_requests" value="'.(ALLOW_INSTRUCTOR_REQUESTS ? 'TRUE' : 'FALSE').'" />';
121 echo '<input type="hidden" name="allow_instructor_requests" value="'.$_defaults['allow_instructor_requests'].'" />';
124 if (defined('AT_EMAIL_CONFIRMATION')) {
125 echo '<input type="hidden" name="email_confirmation" value="'.(AT_EMAIL_CONFIRMATION ? 'TRUE' : 'FALSE').'" />';
127 echo '<input type="hidden" name="email_confirmation" value="FALSE" />';
130 if (defined('AT_MASTER_LIST')) {
131 echo '<input type="hidden" name="master_list" value="'.(AT_MASTER_LIST ? 'TRUE' : 'FALSE').'" />';
133 echo '<input type="hidden" name="master_list" value="FALSE" />';
135 if (defined('AT_ENABLE_HANDBOOK_NOTES')) {
136 echo '<input type="hidden" name="enable_handbook_notes" value="'.(AT_ENABLE_HANDBOOK_NOTES ? 'TRUE' : 'FALSE').'" />';
138 echo '<input type="hidden" name="enable_handbook_notes" value="FALSE" />';
140 if (defined('AUTO_APPROVE_INSTRUCTORS')) {
141 echo '<input type="hidden" name="auto_approve" value="'.(AUTO_APPROVE_INSTRUCTORS ? 'TRUE' : 'FALSE').'" />';
143 echo '<input type="hidden" name="auto_approve" value="'.$_defaults['auto_approve'].'" />';
146 if (isset($MaxFileSize)) {
147 echo '<input type="hidden" name="max_file_size" value="'.$MaxFileSize.'" />';
149 echo '<input type="hidden" name="max_file_size" value="'.$_defaults['max_file_size'].'" />';
151 if (isset($MaxCourseSize)) {
152 echo '<input type="hidden" name="max_course_size" value="'.$MaxCourseSize.'" />';
154 echo '<input type="hidden" name="max_course_size" value="'.$_defaults['max_course_size'].'" />';
156 if (isset($MaxCourseFloat)) {
157 echo '<input type="hidden" name="max_course_float" value="'.$MaxCourseFloat.'" />';
159 echo '<input type="hidden" name="max_course_float" value="' . $_defaults['max_course_float'] . '" />';
162 if (isset($IllegalExtentions)) {
163 echo '<input type="hidden" name="ill_ext" value="' . $IllegalExtentions . '" />';
165 echo '<input type="hidden" name="ill_ext" value="' . $_defaults['ill_ext'] . '" />';
167 if (defined('CACHE_DIR')) {
168 echo '<input type="hidden" name="cache_dir" value="' . CACHE_DIR . '" />';
170 echo '<input type="hidden" name="cache_dir" value="' . $_defaults['cache_dir'] . '" />';
173 if (defined('AT_ENABLE_CATEGORY_THEMES')) {
174 echo '<input type="hidden" name="theme_categories" value="' . (AT_ENABLE_CATEGORY_THEMES ? 'TRUE' : 'FALSE') . '" />';
176 echo '<input type="hidden" name="theme_categories" value="' . $_defaults['theme_categories'] . '" />';
179 if (defined('AT_COURSE_BACKUPS')) {
180 echo '<input type="hidden" name="course_backups" value="' . AT_COURSE_BACKUPS . '" />';
182 echo '<input type="hidden" name="course_backups" value="' . $_defaults['course_backups'] . '" />';
185 if (defined('AT_CONTENT_DIR')) {
186 echo '<input type="hidden" name="content_dir" value="'.AT_CONTENT_DIR.'" />';
188 echo '<input type="hidden" name="content_dir" value="'.$_defaults['content_dir'].'" />';
190 echo '<input type="hidden" name="new_version" value="'.$new_version.'" />';
191 echo '<input type="hidden" name="old_version" value="'.VERSION.'" />';
192 echo '<p align="center"><input type="submit" class="button" value=" Next » " name="submit" /></p></form>';
196 $errors[] = 'Directory was found, but the old configuration file cannot be found.';
199 $errors[] = 'Directory does not exist relative to the new installation.';
203 if (isset($progress)) {
204 print_feedback($progress);
207 if (isset($errors)) {
208 print_errors($errors);
212 <p>Please specify the location of the old ATutor installation.</p>
215 <li>Release Candidate (RC) installations cannot be upgraded.</li>
216 <li>Depending on the size of the existing courses, some steps (particularly 2 and 6) of the upgrade may require considerable time to complete.</li>
217 <li>All installed language packs will be deleted.</li>
218 <li>Some installed themes may not be supported by this version.</li>
219 <li>All extra modules will have to be reinstalled before they can be enabled again.</li>
222 <p>Select the old ATutor installation directory below.</p>
225 $dirs = scandir('../../');
226 $path = realpath('../../').'/';
227 $current_dir = basename(realpath(getcwd() .'../../'));
228 foreach ($dirs as $key => $value) {
229 if ($value == '.' || $value == '..') {
232 if ($current_dir == $value) {
236 if (!is_dir($path . $value) || !file_exists($path . $value . '/include/config.inc.php')) {
242 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="form">
243 <input type="hidden" name="new_version" value="<?php echo $new_version; ?>" />
244 <input type="hidden" name="step" value="1" />
246 <table width="70%" class="tableborder" cellspacing="0" cellpadding="1" border="0" align="center">
248 <td class="row1"><div class="required" title="Required Field">*</div><b><label for="dir">Old Directory Name:</label></b><br />
249 The old directory must be at the same level as the current directory.</td>
250 <td class="row1" valign="middle">
252 <select name="old_path">
253 <?php foreach ($dirs as $dir): ?>
254 <option value="<?php echo htmlspecialchars($dir); ?>"><?php echo $dir; ?>/</option>
267 <br /><p align="center"><input type="submit" class="button" value="Next » " name="submit" /></p>