AC_4897, AC_4898, AC_4899: Multifile uploader fixes.
[acontent.git] / docs / install / include / ustep1.php
1 <?php
2 /************************************************************************/
3 /* AContent                                                             */
4 /************************************************************************/
5 /* Copyright (c) 2010                                                   */
6 /* Inclusive Design Institute                                           */
7 /*                                                                      */
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 /************************************************************************/
12
13 if (!defined('TR_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/constants.inc.php');
23                         $progress[] = 'Found AContent version <kbd><b>'.VERSION . '</b></kbd> in path <kbd><b>'.$_POST['old_path'].'</b></kbd>.';
24
25                         if (!version_compare(VERSION, $new_version, '<')) {
26                                 $errors[] = 'The version upgrading (<kbd><b>'.VERSION.'</b></kbd>) is not older than the new version (<kbd><b>'.$new_version.'</b></kbd>).';
27                         }
28
29                         if (!$errors) {
30                                 $progress[] = 'Will be upgrading from version <kbd><b>'.VERSION.'</b></kbd> to version <kbd><b>'.$new_version.'</b></kbd>.';
31                                 print_feedback($progress);
32
33                                 require('../../'.$_POST['old_path'] . '/include/config.inc.php');
34
35                                 echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post" name="form">';
36                                 echo '<input type="hidden" name="step" value="2" />';
37                                 echo '<input type="hidden" name="old_path" value="'.$_POST['old_path'].'" />';
38
39                                 echo '<input type="hidden" name="db_login" value="'.urlencode(DB_USER).'" />';
40                                 echo '<input type="hidden" name="db_password" value="'.urlencode(DB_PASSWORD).'" />';
41                                 echo '<input type="hidden" name="db_host" value="'.DB_HOST.'" />';
42                                 if (defined('DB_PORT')) {
43                                         echo '<input type="hidden" name="db_port" value="'.DB_PORT.'" />';
44                                 } else {
45                                         echo '<input type="hidden" name="db_port" value="3306" />';
46                                 }
47                                 echo '<input type="hidden" name="db_name" value="'.DB_NAME.'" />';
48
49                                 if (defined('TABLE_PREFIX')) {
50                                         echo '<input type="hidden" name="tb_prefix" value="'.TABLE_PREFIX.'" />';
51                                 } else {
52                                         echo '<input type="hidden" name="tb_prefix" value="" />';
53                                 }
54                                 if (defined('SITE_NAME')) {
55                                         echo '<input type="hidden" name="site_name" value="'.urlencode(SITE_NAME).'" />';
56                                 } else {
57                                         echo '<input type="hidden" name="site_name" value="'.$_defaults['site_name'].'" />';
58                                 }
59                                 if (defined('HEADER_IMAGE')) {
60                                         echo '<input type="hidden" name="header_img" value="'.HEADER_IMAGE.'" />';
61                                 } else {
62                                         echo '<input type="hidden" name="header_img" value="'.$_defaults['header_img'].'" />';
63                                 }
64                                 if (defined('HEADER_LOGO')) {
65                                         echo '<input type="hidden" name="header_logo" value="'.HEADER_LOGO.'" />';
66                                 } else {
67                                         echo '<input type="hidden" name="header_logo" value="'.$_defaults['header_logo'].'" />';
68                                 }
69                                 if (defined('HOME_URL')) {
70                                         echo '<input type="hidden" name="home_url" value="'.HOME_URL.'" />';
71                                 } else {
72                                         echo '<input type="hidden" name="home_url" value="'.$_defaults['home_url'].'" />';
73                                 }
74
75                                 if (defined('MAIL_USE_SMTP')) {
76                                         echo '<input type="hidden" name="smtp" value="'.(MAIL_USE_SMTP ? 'TRUE' : 'FALSE').'" />';
77                                 } else {
78                                         echo '<input type="hidden" name="smtp" value="FALSE" />';
79                                 }
80                                 if (defined('TR_FORCE_GET_FILE')) {
81                                         echo '<input type="hidden" name="get_file" value="'.(TR_FORCE_GET_FILE ? 'TRUE' : 'FALSE').'" />';
82                                 } else {
83                                         echo '<input type="hidden" name="get_file" value="FALSE" />';
84                                 }
85                                 echo '<input type="hidden" name="admin_password" value="'.urlencode(ADMIN_PASSWORD).'" />';
86
87                                 if (defined('ADMIN_USERNAME')) {
88                                         echo '<input type="hidden" name="admin_username" value="'.ADMIN_USERNAME.'" />';
89                                 } else {
90                                         echo '<input type="hidden" name="admin_username" value="'.$_defaults['admin_username'].'" />';
91                                 }
92
93                                 if (defined('ADMIN_EMAIL')) {
94                                         echo '<input type="hidden" name="admin_email" value="'.ADMIN_EMAIL.'" />';
95                                 } else {
96                                         echo '<input type="hidden" name="admin_email" value="'.$_defaults['admin_email'].'" />';
97                                 }
98                                 if (defined('EMAIL')) {
99                                         echo '<input type="hidden" name="contact_email" value="'.EMAIL.'" />';
100                                 } else if (defined('ADMIN_EMAIL')) {
101                                         echo '<input type="hidden" name="contact_email" value="'.ADMIN_EMAIL.'" />';
102                                 } else {
103                                         echo '<input type="hidden" name="contact_email" value="'.$_defaults['admin_email'].'" />';
104                                 }
105
106                                 if (defined('TR_EMAIL_CONFIRMATION')) {
107                                         echo '<input type="hidden" name="email_confirmation" value="'.(TR_EMAIL_CONFIRMATION ? 'TRUE' : 'FALSE').'" />';
108                                 } else {
109                                         echo '<input type="hidden" name="email_confirmation" value="FALSE" />';
110                                 }
111
112                                 if (isset($MaxFileSize)) {
113                                         echo '<input type="hidden" name="max_file_size" value="'.$MaxFileSize.'" />';
114                                 } else {
115                                         echo '<input type="hidden" name="max_file_size" value="'.$_defaults['max_file_size'].'" />';
116                                 }
117                                 
118                                 echo '<input type="hidden" name="ill_ext" value="' . $_defaults['ill_ext'] . '" />';
119
120                                 if (defined('CACHE_DIR')) {
121                                         echo '<input type="hidden" name="cache_dir" value="' . CACHE_DIR . '" />';
122                                 } else {
123                                         echo '<input type="hidden" name="cache_dir" value="' . $_defaults['cache_dir'] . '" />';
124                                 }
125
126                                 if (defined('TR_CONTENT_DIR')) {
127                                         echo '<input type="hidden" name="content_dir" value="'.TR_CONTENT_DIR.'" />';
128                                 } else {
129                                         echo '<input type="hidden" name="content_dir" value="'.$_defaults['content_dir'].'" />';
130                                 }
131                                 echo '<input type="hidden" name="new_version" value="'.$new_version.'" />';
132                                 echo '<input type="hidden" name="old_version" value="'.VERSION.'" />';
133                                 echo '<p align="center"><input type="submit" class="button" value=" Next &raquo; " name="submit" /></p></form>';
134                                 return;
135                         }
136                 } else {
137                         $errors[] = 'Directory was found, but the old configuration file cannot be found.';
138                 }
139         } else {
140                 $errors[] = 'Directory does not exist relative to the new installation.';
141         }
142 }
143
144 if (isset($progress)) {
145         print_feedback($progress);
146 }
147
148 if (isset($errors)) {
149         print_errors($errors);
150 }
151
152 ?>
153 <p>Please specify the location of the old AContent installation.</p>
154
155 <ol>
156         <li>Release Candidate (RC) installations cannot be upgraded.</li>
157         <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>
158         <li>All installed language packs will be deleted.</li>
159         <li>Some installed themes may not be supported by this version.</li>
160         <li>All extra modules will have to be reinstalled before they can be enabled again.</li>
161 </ol>
162
163 <p>Select the old AContent installation directory below.</p>
164
165 <?php
166         $dirs = scandir('../../');
167         $path = realpath('../../').'/';
168         $current_dir = basename(realpath(getcwd() .'../../'));
169         foreach ($dirs as $key => $value) {
170                 if ($value == '.' || $value == '..') {
171                         unset($dirs[$key]);
172                 }
173                 if ($current_dir == $value) {
174                         unset($dirs[$key]);
175                         continue;
176                 }
177                 if (!is_dir($path . $value) || !file_exists($path . $value . '/include/config.inc.php')) {
178                         unset($dirs[$key]);
179                 }
180         }
181 ?>
182
183 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="form">
184 <input type="hidden" name="new_version" value="<?php echo $new_version; ?>" />
185 <input type="hidden" name="step" value="1" />
186
187 <table width="70%" class="tableborder" cellspacing="0" cellpadding="1" border="0" align="center">
188 <tr>
189         <td class="row1"><div class="required" title="Required Field">*</div><b><label for="dir">Old Directory Name:</label></b><br />
190                 The old directory must be at the same level as the current directory.</td>
191                 <td class="row1" valign="middle">
192                 <?php if ($dirs): ?>
193                         <select name="old_path">
194                                 <?php foreach ($dirs as $dir): ?>
195                                         <option value="<?php echo htmlspecialchars($dir); ?>"><?php echo $dir; ?>/</option>
196                                 <?php endforeach; ?>
197                         </select>
198                 <?php else: ?>
199                         <em>None found.</em>
200                 <?php endif; ?>
201                 </td>
202 </tr>
203 </table>
204
205 <br />
206
207 <?php if ($dirs): ?>
208         <br /><p align="center"><input type="submit" class="button" value="Next &raquo; " name="submit" /></p>
209 <?php endif; ?>
210
211 </form>