2 /************************************************************************/
4 /************************************************************************/
5 /* Copyright (c) 2002-2010 */
7 /* This program is free software. You can redistribute it and/or */
8 /* modify it under the terms of the GNU General Public License */
9 /* as published by the Free Software Foundation. */
10 /************************************************************************/
13 if (!defined('AT_INCLUDE_PATH')) { exit; }
14 session_unset(); //clear session before using it
16 print_progress($step);
18 if (isset($_POST['submit']) && (trim($_POST['old_path']) != '')) {
19 if ((strpos($_POST['old_path'], '/') === false) && is_dir('../../'.$_POST['old_path'])) {
20 if ( file_exists('../../'.$_POST['old_path'] . '/include/config.inc.php') ) {
22 require('../../'.$_POST['old_path'] . '/include/lib/constants.inc.php');
23 if (!defined('VERSION')) {
24 $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.';
26 $progress[] = 'Found ATutor version <kbd><b>'.VERSION . '</b></kbd> in path <kbd><b>'.$_POST['old_path'].'</b></kbd>.';
28 if (!version_compare(VERSION, $new_version, '<')) {
29 $errors[] = 'The version upgrading (<kbd><b>'.VERSION.'</b></kbd>) is not older than the new version (<kbd><b>'.$new_version.'</b></kbd>).';
33 $progress[] = 'Will be upgrading from version <kbd><b>'.VERSION.'</b></kbd> to version <kbd><b>'.$new_version.'</b></kbd>.';
34 print_feedback($progress);
36 require('../../'.$_POST['old_path'] . '/include/config.inc.php');
38 if (is_array($IllegalExtentions)) {
39 $IllegalExtentions = implode(',', $IllegalExtentions);
42 echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post" name="form">';
43 echo '<input type="hidden" name="step" value="2" />';
44 echo '<input type="hidden" name="old_path" value="'.$_POST['old_path'].'" />';
46 echo '<input type="hidden" name="db_login" value="'.urlencode(DB_USER).'" />';
47 echo '<input type="hidden" name="db_password" value="'.urlencode(DB_PASSWORD).'" />';
48 echo '<input type="hidden" name="db_host" value="'.DB_HOST.'" />';
49 if (defined('DB_PORT')) {
50 echo '<input type="hidden" name="db_port" value="'.DB_PORT.'" />';
52 echo '<input type="hidden" name="db_port" value="3306" />';
54 echo '<input type="hidden" name="db_name" value="'.DB_NAME.'" />';
56 if (defined('TABLE_PREFIX')) {
57 echo '<input type="hidden" name="tb_prefix" value="'.TABLE_PREFIX.'" />';
59 echo '<input type="hidden" name="tb_prefix" value="" />';
61 if (defined('SITE_NAME')) {
62 echo '<input type="hidden" name="site_name" value="'.urlencode(SITE_NAME).'" />';
64 echo '<input type="hidden" name="site_name" value="'.$_defaults['site_name'].'" />';
66 if (defined('HEADER_IMAGE')) {
67 echo '<input type="hidden" name="header_img" value="'.HEADER_IMAGE.'" />';
69 echo '<input type="hidden" name="header_img" value="'.$_defaults['header_img'].'" />';
71 if (defined('HEADER_LOGO')) {
72 echo '<input type="hidden" name="header_logo" value="'.HEADER_LOGO.'" />';
74 echo '<input type="hidden" name="header_logo" value="'.$_defaults['header_logo'].'" />';
76 if (defined('HOME_URL')) {
77 echo '<input type="hidden" name="home_url" value="'.HOME_URL.'" />';
79 echo '<input type="hidden" name="home_url" value="'.$_defaults['home_url'].'" />';
82 if (defined('MAIL_USE_SMTP')) {
83 echo '<input type="hidden" name="smtp" value="'.(MAIL_USE_SMTP ? 'TRUE' : 'FALSE').'" />';
85 echo '<input type="hidden" name="smtp" value="FALSE" />';
87 if (defined('AT_FORCE_GET_FILE')) {
88 echo '<input type="hidden" name="get_file" value="'.(AT_FORCE_GET_FILE ? 'TRUE' : 'FALSE').'" />';
90 echo '<input type="hidden" name="get_file" value="FALSE" />';
92 echo '<input type="hidden" name="admin_password" value="'.urlencode(ADMIN_PASSWORD).'" />';
94 if (defined('ADMIN_USERNAME')) {
95 echo '<input type="hidden" name="admin_username" value="'.ADMIN_USERNAME.'" />';
97 echo '<input type="hidden" name="admin_username" value="'.$_defaults['admin_username'].'" />';
100 if (defined('ADMIN_EMAIL')) {
101 echo '<input type="hidden" name="admin_email" value="'.ADMIN_EMAIL.'" />';
103 echo '<input type="hidden" name="admin_email" value="'.$_defaults['admin_email'].'" />';
105 if (defined('EMAIL')) {
106 echo '<input type="hidden" name="contact_email" value="'.EMAIL.'" />';
107 } else if (defined('ADMIN_EMAIL')) {
108 echo '<input type="hidden" name="contact_email" value="'.ADMIN_EMAIL.'" />';
110 echo '<input type="hidden" name="contact_email" value="'.$_defaults['admin_email'].'" />';
112 if (defined('EMAIL_NOTIFY')) {
113 echo '<input type="hidden" name="email_notification" value="'.(EMAIL_NOTIFY ? 'TRUE' : 'FALSE').'" />';
115 echo '<input type="hidden" name="email_notification" value="'.$_defaults['email_notification'].'" />';
117 if (defined('ALLOW_INSTRUCTOR_REQUESTS')) {
118 echo '<input type="hidden" name="allow_instructor_requests" value="'.(ALLOW_INSTRUCTOR_REQUESTS ? 'TRUE' : 'FALSE').'" />';
120 echo '<input type="hidden" name="allow_instructor_requests" value="'.$_defaults['allow_instructor_requests'].'" />';
123 if (defined('AT_EMAIL_CONFIRMATION')) {
124 echo '<input type="hidden" name="email_confirmation" value="'.(AT_EMAIL_CONFIRMATION ? 'TRUE' : 'FALSE').'" />';
126 echo '<input type="hidden" name="email_confirmation" value="FALSE" />';
129 if (defined('AT_MASTER_LIST')) {
130 echo '<input type="hidden" name="master_list" value="'.(AT_MASTER_LIST ? 'TRUE' : 'FALSE').'" />';
132 echo '<input type="hidden" name="master_list" value="FALSE" />';
134 if (defined('AT_ENABLE_HANDBOOK_NOTES')) {
135 echo '<input type="hidden" name="enable_handbook_notes" value="'.(AT_ENABLE_HANDBOOK_NOTES ? 'TRUE' : 'FALSE').'" />';
137 echo '<input type="hidden" name="enable_handbook_notes" value="FALSE" />';
139 if (defined('AUTO_APPROVE_INSTRUCTORS')) {
140 echo '<input type="hidden" name="auto_approve" value="'.(AUTO_APPROVE_INSTRUCTORS ? 'TRUE' : 'FALSE').'" />';
142 echo '<input type="hidden" name="auto_approve" value="'.$_defaults['auto_approve'].'" />';
145 if (isset($MaxFileSize)) {
146 echo '<input type="hidden" name="max_file_size" value="'.$MaxFileSize.'" />';
148 echo '<input type="hidden" name="max_file_size" value="'.$_defaults['max_file_size'].'" />';
150 if (isset($MaxCourseSize)) {
151 echo '<input type="hidden" name="max_course_size" value="'.$MaxCourseSize.'" />';
153 echo '<input type="hidden" name="max_course_size" value="'.$_defaults['max_course_size'].'" />';
155 if (isset($MaxCourseFloat)) {
156 echo '<input type="hidden" name="max_course_float" value="'.$MaxCourseFloat.'" />';
158 echo '<input type="hidden" name="max_course_float" value="' . $_defaults['max_course_float'] . '" />';
161 if (isset($IllegalExtentions)) {
162 echo '<input type="hidden" name="ill_ext" value="' . $IllegalExtentions . '" />';
164 echo '<input type="hidden" name="ill_ext" value="' . $_defaults['ill_ext'] . '" />';
166 if (defined('CACHE_DIR')) {
167 echo '<input type="hidden" name="cache_dir" value="' . CACHE_DIR . '" />';
169 echo '<input type="hidden" name="cache_dir" value="' . $_defaults['cache_dir'] . '" />';
172 if (defined('AT_ENABLE_CATEGORY_THEMES')) {
173 echo '<input type="hidden" name="theme_categories" value="' . (AT_ENABLE_CATEGORY_THEMES ? 'TRUE' : 'FALSE') . '" />';
175 echo '<input type="hidden" name="theme_categories" value="' . $_defaults['theme_categories'] . '" />';
178 if (defined('AT_COURSE_BACKUPS')) {
179 echo '<input type="hidden" name="course_backups" value="' . AT_COURSE_BACKUPS . '" />';
181 echo '<input type="hidden" name="course_backups" value="' . $_defaults['course_backups'] . '" />';
184 if (defined('AT_CONTENT_DIR')) {
185 echo '<input type="hidden" name="content_dir" value="'.AT_CONTENT_DIR.'" />';
187 echo '<input type="hidden" name="content_dir" value="'.$_defaults['content_dir'].'" />';
189 echo '<input type="hidden" name="new_version" value="'.$new_version.'" />';
190 echo '<input type="hidden" name="old_version" value="'.VERSION.'" />';
191 echo '<p align="center"><input type="submit" class="button" value=" Next » " name="submit" /></p></form>';
195 $errors[] = 'Directory was found, but the old configuration file cannot be found.';
198 $errors[] = 'Directory does not exist relative to the new installation.';
202 if (isset($progress)) {
203 print_feedback($progress);
206 if (isset($errors)) {
207 print_errors($errors);
211 <p>Please specify the location of the old ATutor installation.</p>
214 <li>Release Candidate (RC) installations cannot be upgraded.</li>
215 <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>
216 <li>All installed language packs will be deleted.</li>
217 <li>Some installed themes may not be supported by this version.</li>
218 <li>All extra modules will have to be reinstalled before they can be enabled again.</li>
221 <p>Select the old ATutor installation directory below.</p>
224 $dirs = scandir('../../');
225 $path = realpath('../../').'/';
226 $current_dir = basename(realpath(getcwd() .'../../'));
227 foreach ($dirs as $key => $value) {
228 if ($value == '.' || $value == '..') {
231 if ($current_dir == $value) {
235 if (!is_dir($path . $value) || !file_exists($path . $value . '/include/config.inc.php')) {
241 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="form">
242 <input type="hidden" name="new_version" value="<?php echo $new_version; ?>" />
243 <input type="hidden" name="step" value="1" />
245 <table width="70%" class="tableborder" cellspacing="0" cellpadding="1" border="0" align="center">
247 <td class="row1"><span class="required" title="Required Field">*</span><b><label for="dir">Old Directory Name:</label></b><br />
248 The old directory must be at the same level as the current directory.</td>
249 <td class="row1" valign="middle">
251 <select name="old_path">
252 <?php foreach ($dirs as $dir): ?>
253 <option value="<?php echo htmlspecialchars($dir); ?>"><?php echo $dir; ?>/</option>
266 <br /><p align="center"><input type="submit" class="button" value="Next » " name="submit" /></p>