remove old readme
[atutor.git] / docs / install / include / ustep1.php
1 <?php
2 /************************************************************************/
3 /* ATutor                                                                                                                               */
4 /************************************************************************/
5 /* Copyright (c) 2002-2010                                              */
6 /* http://atutor.ca                                                     */
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 /************************************************************************/
11 // $Id$
12
13 if (!defined('AT_INCLUDE_PATH')) { exit; }
14 session_unset();        //clear session before using it
15 $_SESSION = array();
16 print_progress($step);
17
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') ) {
21                         
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.';
25                         } else {
26                                 $progress[] = 'Found ATutor version <kbd><b>'.VERSION . '</b></kbd> in path <kbd><b>'.$_POST['old_path'].'</b></kbd>.';
27                         }
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>).';
30                         }
31
32                         if (!$errors) {
33                                 $progress[] = 'Will be upgrading from version <kbd><b>'.VERSION.'</b></kbd> to version <kbd><b>'.$new_version.'</b></kbd>.';
34                                 print_feedback($progress);
35
36                                 require('../../'.$_POST['old_path'] . '/include/config.inc.php');
37
38                                 if (is_array($IllegalExtentions)) {
39                                         $IllegalExtentions = implode(',', $IllegalExtentions);
40                                 }
41
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'].'" />';
45
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.'" />';
51                                 } else {
52                                         echo '<input type="hidden" name="db_port" value="3306" />';
53                                 }
54                                 echo '<input type="hidden" name="db_name" value="'.DB_NAME.'" />';
55
56                                 if (defined('TABLE_PREFIX')) {
57                                         echo '<input type="hidden" name="tb_prefix" value="'.TABLE_PREFIX.'" />';
58                                 } else {
59                                         echo '<input type="hidden" name="tb_prefix" value="" />';
60                                 }
61                                 if (defined('SITE_NAME')) {
62                                         echo '<input type="hidden" name="site_name" value="'.urlencode(SITE_NAME).'" />';
63                                 } else {
64                                         echo '<input type="hidden" name="site_name" value="'.$_defaults['site_name'].'" />';
65                                 }
66                                 if (defined('HEADER_IMAGE')) {
67                                         echo '<input type="hidden" name="header_img" value="'.HEADER_IMAGE.'" />';
68                                 } else {
69                                         echo '<input type="hidden" name="header_img" value="'.$_defaults['header_img'].'" />';
70                                 }
71                                 if (defined('HEADER_LOGO')) {
72                                         echo '<input type="hidden" name="header_logo" value="'.HEADER_LOGO.'" />';
73                                 } else {
74                                         echo '<input type="hidden" name="header_logo" value="'.$_defaults['header_logo'].'" />';
75                                 }
76                                 if (defined('HOME_URL')) {
77                                         echo '<input type="hidden" name="home_url" value="'.HOME_URL.'" />';
78                                 } else {
79                                         echo '<input type="hidden" name="home_url" value="'.$_defaults['home_url'].'" />';
80                                 }
81
82                                 if (defined('MAIL_USE_SMTP')) {
83                                         echo '<input type="hidden" name="smtp" value="'.(MAIL_USE_SMTP ? 'TRUE' : 'FALSE').'" />';
84                                 } else {
85                                         echo '<input type="hidden" name="smtp" value="FALSE" />';
86                                 }
87                                 if (defined('AT_FORCE_GET_FILE')) {
88                                         echo '<input type="hidden" name="get_file" value="'.(AT_FORCE_GET_FILE ? 'TRUE' : 'FALSE').'" />';
89                                 } else {
90                                         echo '<input type="hidden" name="get_file" value="FALSE" />';
91                                 }
92                                 echo '<input type="hidden" name="admin_password" value="'.urlencode(ADMIN_PASSWORD).'" />';
93
94                                 if (defined('ADMIN_USERNAME')) {
95                                         echo '<input type="hidden" name="admin_username" value="'.ADMIN_USERNAME.'" />';
96                                 } else {
97                                         echo '<input type="hidden" name="admin_username" value="'.$_defaults['admin_username'].'" />';
98                                 }
99
100                                 if (defined('ADMIN_EMAIL')) {
101                                         echo '<input type="hidden" name="admin_email" value="'.ADMIN_EMAIL.'" />';
102                                 } else {
103                                         echo '<input type="hidden" name="admin_email" value="'.$_defaults['admin_email'].'" />';
104                                 }
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.'" />';
109                                 } else {
110                                         echo '<input type="hidden" name="contact_email" value="'.$_defaults['admin_email'].'" />';
111                                 }
112                                 if (defined('EMAIL_NOTIFY')) {
113                                         echo '<input type="hidden" name="email_notification" value="'.(EMAIL_NOTIFY ? 'TRUE' : 'FALSE').'" />';
114                                 } else {
115                                         echo '<input type="hidden" name="email_notification" value="'.$_defaults['email_notification'].'" />';
116                                 }
117                                 if (defined('ALLOW_INSTRUCTOR_REQUESTS')) {
118                                         echo '<input type="hidden" name="allow_instructor_requests" value="'.(ALLOW_INSTRUCTOR_REQUESTS ? 'TRUE' : 'FALSE').'" />';
119                                 } else {
120                                         echo '<input type="hidden" name="allow_instructor_requests" value="'.$_defaults['allow_instructor_requests'].'" />';
121                                 }
122
123                                 if (defined('AT_EMAIL_CONFIRMATION')) {
124                                         echo '<input type="hidden" name="email_confirmation" value="'.(AT_EMAIL_CONFIRMATION ? 'TRUE' : 'FALSE').'" />';
125                                 } else {
126                                         echo '<input type="hidden" name="email_confirmation" value="FALSE" />';
127                                 }
128                                 
129                                 if (defined('AT_MASTER_LIST')) {
130                                         echo '<input type="hidden" name="master_list" value="'.(AT_MASTER_LIST ? 'TRUE' : 'FALSE').'" />';
131                                 } else {
132                                         echo '<input type="hidden" name="master_list" value="FALSE" />';
133                                 }
134                                 if (defined('AT_ENABLE_HANDBOOK_NOTES')) {
135                                         echo '<input type="hidden" name="enable_handbook_notes" value="'.(AT_ENABLE_HANDBOOK_NOTES ? 'TRUE' : 'FALSE').'" />';
136                                 } else {
137                                         echo '<input type="hidden" name="enable_handbook_notes" value="FALSE" />';
138                                 }
139                                 if (defined('AUTO_APPROVE_INSTRUCTORS')) {
140                                         echo '<input type="hidden" name="auto_approve" value="'.(AUTO_APPROVE_INSTRUCTORS ? 'TRUE' : 'FALSE').'" />';
141                                 } else {
142                                         echo '<input type="hidden" name="auto_approve" value="'.$_defaults['auto_approve'].'" />';
143                                 }
144
145                                 if (isset($MaxFileSize)) {
146                                         echo '<input type="hidden" name="max_file_size" value="'.$MaxFileSize.'" />';
147                                 } else {
148                                         echo '<input type="hidden" name="max_file_size" value="'.$_defaults['max_file_size'].'" />';
149                                 }
150                                 if (isset($MaxCourseSize)) {
151                                         echo '<input type="hidden" name="max_course_size" value="'.$MaxCourseSize.'" />';
152                                 } else {
153                                         echo '<input type="hidden" name="max_course_size" value="'.$_defaults['max_course_size'].'" />';
154                                 }
155                                 if (isset($MaxCourseFloat)) {
156                                         echo '<input type="hidden" name="max_course_float" value="'.$MaxCourseFloat.'" />';
157                                 } else {
158                                         echo '<input type="hidden" name="max_course_float" value="' . $_defaults['max_course_float'] . '" />';
159                                 }
160                                 
161                                 if (isset($IllegalExtentions)) {
162                                         echo '<input type="hidden" name="ill_ext" value="' . $IllegalExtentions . '" />';
163                                 } else {
164                                         echo '<input type="hidden" name="ill_ext" value="' . $_defaults['ill_ext'] . '" />';
165                                 }
166                                 if (defined('CACHE_DIR')) {
167                                         echo '<input type="hidden" name="cache_dir" value="' . CACHE_DIR . '" />';
168                                 } else {
169                                         echo '<input type="hidden" name="cache_dir" value="' . $_defaults['cache_dir'] . '" />';
170                                 }
171
172                                 if (defined('AT_ENABLE_CATEGORY_THEMES')) {
173                                         echo '<input type="hidden" name="theme_categories" value="' . (AT_ENABLE_CATEGORY_THEMES ? 'TRUE' : 'FALSE') . '" />';
174                                 } else {
175                                         echo '<input type="hidden" name="theme_categories" value="' . $_defaults['theme_categories'] . '" />';
176                                 }
177
178                                 if (defined('AT_COURSE_BACKUPS')) {
179                                         echo '<input type="hidden" name="course_backups" value="' . AT_COURSE_BACKUPS . '" />';
180                                 } else {
181                                         echo '<input type="hidden" name="course_backups" value="' . $_defaults['course_backups'] . '" />';
182                                 }
183
184                                 if (defined('AT_CONTENT_DIR')) {
185                                         echo '<input type="hidden" name="content_dir" value="'.AT_CONTENT_DIR.'" />';
186                                 } else {
187                                         echo '<input type="hidden" name="content_dir" value="'.$_defaults['content_dir'].'" />';
188                                 }
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 &raquo; " name="submit" /></p></form>';
192                                 return;
193                         }
194                 } else {
195                         $errors[] = 'Directory was found, but the old configuration file cannot be found.';
196                 }
197         } else {
198                 $errors[] = 'Directory does not exist relative to the new installation.';
199         }
200 }
201
202 if (isset($progress)) {
203         print_feedback($progress);
204 }
205
206 if (isset($errors)) {
207         print_errors($errors);
208 }
209
210 ?>
211 <p>Please specify the location of the old ATutor installation.</p>
212
213 <ol>
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>
219 </ol>
220
221 <p>Select the old ATutor installation directory below.</p>
222
223 <?php
224         $dirs = scandir('../../');
225         $path = realpath('../../').'/';
226         $current_dir = basename(realpath(getcwd() .'../../'));
227         foreach ($dirs as $key => $value) {
228                 if ($value == '.' || $value == '..') {
229                         unset($dirs[$key]);
230                 }
231                 if ($current_dir == $value) {
232                         unset($dirs[$key]);
233                         continue;
234                 }
235                 if (!is_dir($path . $value) || !file_exists($path . $value . '/include/config.inc.php')) {
236                         unset($dirs[$key]);
237                 }
238         }
239 ?>
240
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" />
244
245 <table width="70%" class="tableborder" cellspacing="0" cellpadding="1" border="0" align="center">
246 <tr>
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">
250                 <?php if ($dirs): ?>
251                         <select name="old_path">
252                                 <?php foreach ($dirs as $dir): ?>
253                                         <option value="<?php echo htmlspecialchars($dir); ?>"><?php echo $dir; ?>/</option>
254                                 <?php endforeach; ?>
255                         </select>
256                 <?php else: ?>
257                         <em>None found.</em>
258                 <?php endif; ?>
259                 </td>
260 </tr>
261 </table>
262
263 <br />
264
265 <?php if ($dirs): ?>
266         <br /><p align="center"><input type="submit" class="button" value="Next &raquo; " name="submit" /></p>
267 <?php endif; ?>
268
269 </form>