71 $stg_finish = $ui->add_stage($lang->get('upgrade_stg_finish'), true); |
71 $stg_finish = $ui->add_stage($lang->get('upgrade_stg_finish'), true); |
72 |
72 |
73 // Version check |
73 // Version check |
74 if ( enano_version() == installer_enano_version() ) |
74 if ( enano_version() == installer_enano_version() ) |
75 { |
75 { |
76 $ui->show_header(); |
76 $ui->show_header(); |
77 $link_home = makeUrl(get_main_page(), false, true); |
77 $link_home = makeUrl(get_main_page(), false, true); |
78 echo '<h3>' . $lang->get('upgrade_err_current_title') . '</h3>' . |
78 echo '<h3>' . $lang->get('upgrade_err_current_title') . '</h3>' . |
79 '<p>' . $lang->get('upgrade_err_current_body', array('mainpage_link' => $link_home)) . '</p>' . |
79 '<p>' . $lang->get('upgrade_err_current_body', array('mainpage_link' => $link_home)) . '</p>' . |
80 '<p>' . $lang->get('upgrade_err_current_body_para2', array('mainpage_link' => $link_home)) . '</p>'; |
80 '<p>' . $lang->get('upgrade_err_current_body_para2', array('mainpage_link' => $link_home)) . '</p>'; |
81 $ui->show_footer(); |
81 $ui->show_footer(); |
82 exit(); |
82 exit(); |
83 } |
83 } |
84 |
84 |
85 // Start session manager |
85 // Start session manager |
86 $session->start(); |
86 $session->start(); |
87 |
87 |
88 // Welcome page |
88 // Welcome page |
89 if ( !isset($_GET['stage']) ) |
89 if ( !isset($_GET['stage']) ) |
90 { |
90 { |
91 $ui->show_header(); |
91 $ui->show_header(); |
92 |
92 |
93 if ( preg_match('/1\.0/', enano_version()) ) |
93 if ( preg_match('/1\.0/', enano_version()) ) |
94 { |
94 { |
95 // Migrating from 1.0.x |
95 // Migrating from 1.0.x |
96 echo '<h3>' . $lang->get('upgrade_welcome_banshee_heading', array('enano_version' => installer_enano_version())) . '</h3>'; |
96 echo '<h3>' . $lang->get('upgrade_welcome_banshee_heading', array('enano_version' => installer_enano_version())) . '</h3>'; |
97 echo '<p>' . $lang->get('upgrade_welcome_banshee_para1') . '</p>'; |
97 echo '<p>' . $lang->get('upgrade_welcome_banshee_para1') . '</p>'; |
98 echo '<p>' . $lang->get('upgrade_welcome_banshee_para2') . '</p>'; |
98 echo '<p>' . $lang->get('upgrade_welcome_banshee_para2') . '</p>'; |
99 } |
99 } |
100 else |
100 else |
101 { |
101 { |
102 // Upgrading from 1.1.x/1.2.x |
102 // Upgrading from 1.1.x/1.2.x |
103 echo '<h3>' . $lang->get('upgrade_welcome_caoineag_heading', array('enano_version' => installer_enano_version())) . '</h3>'; |
103 echo '<h3>' . $lang->get('upgrade_welcome_caoineag_heading', array('enano_version' => installer_enano_version())) . '</h3>'; |
104 echo '<p>' . $lang->get('upgrade_welcome_caoineag_para1') . '</p>'; |
104 echo '<p>' . $lang->get('upgrade_welcome_caoineag_para1') . '</p>'; |
105 } |
105 } |
106 |
106 |
107 echo '<div style="font-size: x-large; text-align: center; margin: 20px 0;">'; |
107 echo '<div style="font-size: x-large; text-align: center; margin: 20px 0;">'; |
108 echo '<a class="abutton" href="' . $session->append_sid('upgrade.php?stage=confirm') . '" style="text-decoration: none;">' . $lang->get('upgrade_welcome_btn_continue') . ' »</a>'; |
108 echo '<a class="abutton" href="' . $session->append_sid('upgrade.php?stage=confirm') . '" style="text-decoration: none;">' . $lang->get('upgrade_welcome_btn_continue') . ' »</a>'; |
109 echo '</div>'; |
109 echo '</div>'; |
110 |
110 |
111 $ui->show_footer(); |
111 $ui->show_footer(); |
112 exit; |
112 exit; |
113 } |
113 } |
114 |
114 |
115 if ( !$session->user_logged_in || ( $session->user_logged_in && $session->auth_level < USER_LEVEL_ADMIN ) ) |
115 if ( !$session->user_logged_in || ( $session->user_logged_in && $session->auth_level < USER_LEVEL_ADMIN ) ) |
116 { |
116 { |
117 // if we're not logged in, destroy any existing session keys in the browser |
117 // if we're not logged in, destroy any existing session keys in the browser |
118 @setcookie('sid', '', time() - 86400); |
118 @setcookie('sid', '', time() - 86400); |
119 |
119 |
120 $ui->set_visible_stage($stg_login); |
120 $ui->set_visible_stage($stg_login); |
121 if ( isset($_POST['do_login']) ) |
121 if ( isset($_POST['do_login']) ) |
122 { |
122 { |
123 if ( !$session->user_logged_in ) |
123 if ( !$session->user_logged_in ) |
124 { |
124 { |
125 $result = $session->login_without_crypto($_POST['username'], $_POST['password'], false, USER_LEVEL_MEMBER); |
125 $result = $session->login_without_crypto($_POST['username'], $_POST['password'], false, USER_LEVEL_MEMBER); |
126 } |
126 } |
127 if ( !isset($result) || ( isset($result) && $result['success']) ) |
127 if ( !isset($result) || ( isset($result) && $result['success']) ) |
128 { |
128 { |
129 $result = $session->login_without_crypto($_POST['username'], $_POST['password'], false, USER_LEVEL_ADMIN); |
129 $result = $session->login_without_crypto($_POST['username'], $_POST['password'], false, USER_LEVEL_ADMIN); |
130 if ( $result['success'] ) |
130 if ( $result['success'] ) |
131 { |
131 { |
132 header('HTTP/1.1 302 Some kind of redirect with implied no content'); |
132 header('HTTP/1.1 302 Some kind of redirect with implied no content'); |
133 header('Location: ' . scriptPath . '/install/' . $session->append_sid('upgrade.php?stage=confirm')); |
133 header('Location: ' . scriptPath . '/install/' . $session->append_sid('upgrade.php?stage=confirm')); |
134 exit(); |
134 exit(); |
135 } |
135 } |
136 } |
136 } |
137 } |
137 } |
138 |
138 |
139 $ui->show_header(); |
139 $ui->show_header(); |
140 |
140 |
141 ?> |
141 ?> |
142 <h3><?php echo $lang->get('upgrade_login_msg_auth_needed_title'); ?></h3> |
142 <h3><?php echo $lang->get('upgrade_login_msg_auth_needed_title'); ?></h3> |
143 <?php |
143 <?php |
144 |
144 |
145 echo '<form action="upgrade.php?stage=login" method="post">'; |
145 echo '<form action="upgrade.php?stage=login" method="post">'; |
146 |
146 |
147 if ( isset($result) ) |
147 if ( isset($result) ) |
148 { |
148 { |
149 echo '<b>' . $lang->get('upgrade_login_err_failed', array('error_code' => $result['error'])) . '</b>'; |
149 echo '<b>' . $lang->get('upgrade_login_err_failed', array('error_code' => $result['error'])) . '</b>'; |
150 } |
150 } |
151 |
151 |
152 ?> |
152 ?> |
153 <p><?php |
153 <p><?php |
154 if ( $session->user_logged_in ) |
154 if ( $session->user_logged_in ) |
155 { |
155 { |
156 echo $lang->get('upgrade_login_msg_auth_needed_body_level2'); |
156 echo $lang->get('upgrade_login_msg_auth_needed_body_level2'); |
157 } |
157 } |
158 else |
158 else |
159 { |
159 { |
160 echo $lang->get('upgrade_login_msg_auth_needed_body_level1'); |
160 echo $lang->get('upgrade_login_msg_auth_needed_body_level1'); |
161 } |
161 } |
162 ?></p> |
162 ?></p> |
163 <p> |
163 <p> |
164 <?php echo $lang->get('upgrade_login_msg_local_auth'); ?> |
164 <?php echo $lang->get('upgrade_login_msg_local_auth'); ?> |
165 </p> |
165 </p> |
166 <table border="0" cellspacing="0" cellpadding="5" style="margin: 0 auto;"> |
166 <table border="0" cellspacing="0" cellpadding="5" style="margin: 0 auto;"> |
167 <tr> |
167 <tr> |
168 <td><?php echo $lang->get('user_login_field_username'); ?>:</td> |
168 <td><?php echo $lang->get('user_login_field_username'); ?>:</td> |
169 <td><input type="text" name="username" tabindex="1" /></td> |
169 <td><input type="text" name="username" tabindex="1" /></td> |
170 </tr> |
170 </tr> |
171 <tr> |
171 <tr> |
172 <td><?php echo $lang->get('user_login_field_password'); ?>:</td> |
172 <td><?php echo $lang->get('user_login_field_password'); ?>:</td> |
173 <td><input type="password" name="password" tabindex="2" /></td> |
173 <td><input type="password" name="password" tabindex="2" /></td> |
174 </tr> |
174 </tr> |
175 <tr> |
175 <tr> |
176 <td colspan="2" style="text-align: center;"> |
176 <td colspan="2" style="text-align: center;"> |
177 <input type="submit" name="do_login" value="<?php echo $lang->get('upgrade_login_btn_login'); ?>" tabindex="3" /> |
177 <input type="submit" name="do_login" value="<?php echo $lang->get('upgrade_login_btn_login'); ?>" tabindex="3" /> |
178 </td> |
178 </td> |
179 </tr> |
179 </tr> |
180 </table> |
180 </table> |
181 <?php |
181 <?php |
182 |
182 |
183 echo '</form>'; |
183 echo '</form>'; |
184 |
184 |
185 $ui->show_footer(); |
185 $ui->show_footer(); |
186 exit(); |
186 exit(); |
187 } |
187 } |
188 |
188 |
189 if ( isset($_GET['stage']) && @$_GET['stage'] == 'pimpmyenano' ) |
189 if ( isset($_GET['stage']) && @$_GET['stage'] == 'pimpmyenano' ) |
190 { |
190 { |
191 $ui->set_visible_stage($stg_upgrade); |
191 $ui->set_visible_stage($stg_upgrade); |
192 } |
192 } |
193 else if ( isset($_GET['stage']) && @$_GET['stage'] == 'postpimp' ) |
193 else if ( isset($_GET['stage']) && @$_GET['stage'] == 'postpimp' ) |
194 { |
194 { |
195 $ui->set_visible_stage($stg_finish); |
195 $ui->set_visible_stage($stg_finish); |
196 } |
196 } |
197 else |
197 else |
198 { |
198 { |
199 $ui->set_visible_stage($stg_confirm); |
199 $ui->set_visible_stage($stg_confirm); |
200 } |
200 } |
201 |
201 |
202 // The real migration code |
202 // The real migration code |
203 $ui->show_header(); |
203 $ui->show_header(); |
204 |
204 |
205 if ( isset($_GET['stage']) && @$_GET['stage'] == 'pimpmyenano' ) |
205 if ( isset($_GET['stage']) && @$_GET['stage'] == 'pimpmyenano' ) |
206 { |
206 { |
207 /* |
207 /* |
208 HOW DOES ENANO'S UPGRADER WORK? |
208 HOW DOES ENANO'S UPGRADER WORK? |
209 |
209 |
210 Versions of Enano are organized into branches and then specific versions by |
210 Versions of Enano are organized into branches and then specific versions by |
211 version number. The upgrader works by using a list of known version numbers |
211 version number. The upgrader works by using a list of known version numbers |
212 and then systematically executing upgrade schemas for each version. |
212 and then systematically executing upgrade schemas for each version. |
213 |
213 |
214 When the user requests an upgrade, the first thing performed is a migration |
214 When the user requests an upgrade, the first thing performed is a migration |
215 check, which verifies that they are within the right branch. If they are not |
215 check, which verifies that they are within the right branch. If they are not |
216 within the right branch the upgrade framework will load a migration script |
216 within the right branch the upgrade framework will load a migration script |
217 which will define a function named MIGRATE(). Performing more than one |
217 which will define a function named MIGRATE(). Performing more than one |
218 migration in one pass will probably never be supported. How that works for |
218 migration in one pass will probably never be supported. How that works for |
219 UX in 1.3.x/1.4.x I know not yet. |
219 UX in 1.3.x/1.4.x I know not yet. |
220 |
220 |
221 After performing any necessary branch migrations, the framework will perform |
221 After performing any necessary branch migrations, the framework will perform |
222 any upgrades within the target branch, which is the first two parts |
222 any upgrades within the target branch, which is the first two parts |
223 (delimited by periods) of the installer's version number defined in the |
223 (delimited by periods) of the installer's version number defined in the |
224 installer's common.php. |
224 installer's common.php. |
225 |
225 |
226 enano_perform_upgrade() will only do upgrades. Not migrations. The two as |
226 enano_perform_upgrade() will only do upgrades. Not migrations. The two as |
227 illustrated within this installer are very different. |
227 illustrated within this installer are very different. |
228 */ |
228 */ |
229 |
229 |
230 // Do we need to run the migration first? |
230 // Do we need to run the migration first? |
231 list($major_version, $minor_version) = explode('.', preg_replace('/^upg-/', '', enano_version())); |
231 list($major_version, $minor_version) = explode('.', preg_replace('/^upg-/', '', enano_version())); |
232 $current_branch = "$major_version.$minor_version"; |
232 $current_branch = "$major_version.$minor_version"; |
233 |
233 |
234 list($major_version, $minor_version) = explode('.', installer_enano_version()); |
234 list($major_version, $minor_version) = explode('.', installer_enano_version()); |
235 $target_branch = "$major_version.$minor_version"; |
235 $target_branch = "$major_version.$minor_version"; |
236 |
236 |
237 if ( $target_branch != $current_branch ) |
237 if ( $target_branch != $current_branch ) |
238 { |
238 { |
239 // First upgrade to the latest revision of the current branch |
239 // First upgrade to the latest revision of the current branch |
240 enano_perform_upgrade($current_branch); |
240 enano_perform_upgrade($current_branch); |
241 // Branch migration could be tricky and is often highly specific between |
241 // Branch migration could be tricky and is often highly specific between |
242 // major branches, so just include a custom migration script. |
242 // major branches, so just include a custom migration script. |
243 require(ENANO_ROOT . "/install/schemas/upgrade/migration/{$current_branch}-{$target_branch}.php"); |
243 require(ENANO_ROOT . "/install/schemas/upgrade/migration/{$current_branch}-{$target_branch}.php"); |
244 $result = MIGRATE(); |
244 $result = MIGRATE(); |
245 if ( !$result ) |
245 if ( !$result ) |
246 { |
246 { |
247 echo 'Migration failed, there should be an error message above.'; |
247 echo 'Migration failed, there should be an error message above.'; |
248 $ui->show_footer(); |
248 $ui->show_footer(); |
249 exit; |
249 exit; |
250 } |
250 } |
251 } |
251 } |
252 |
252 |
253 // Do the actual upgrade |
253 // Do the actual upgrade |
254 enano_perform_upgrade($target_branch); |
254 enano_perform_upgrade($target_branch); |
255 |
255 |
256 // Mark as upgrade-in-progress |
256 // Mark as upgrade-in-progress |
257 setConfig('enano_version', 'upg-' . installer_enano_version()); |
257 setConfig('enano_version', 'upg-' . installer_enano_version()); |
258 |
258 |
259 ?> |
259 ?> |
260 <h3> |
260 <h3> |
261 <?php echo $lang->get('upgrade_msg_schema_complete_title'); ?> |
261 <?php echo $lang->get('upgrade_msg_schema_complete_title'); ?> |
262 </h3> |
262 </h3> |
263 <p> |
263 <p> |
264 <?php echo $lang->get('upgrade_msg_schema_complete_body'); ?> |
264 <?php echo $lang->get('upgrade_msg_schema_complete_body'); ?> |
265 </p> |
265 </p> |
266 <form action="upgrade.php" method="get" style="text-align: center;"> |
266 <form action="upgrade.php" method="get" style="text-align: center;"> |
267 <input type="hidden" name="auth" value="<?php echo $session->sid_super; ?>" /> |
267 <input type="hidden" name="auth" value="<?php echo $session->sid_super; ?>" /> |
268 <p style="text-align: center;"> |
268 <p style="text-align: center;"> |
269 <button name="stage" value="postpimp" class="submit"> |
269 <button name="stage" value="postpimp" class="submit"> |
270 <?php echo $lang->get('upgrade_btn_continue'); ?> |
270 <?php echo $lang->get('upgrade_btn_continue'); ?> |
271 </button> |
271 </button> |
272 </p> |
272 </p> |
273 </form> |
273 </form> |
274 <?php |
274 <?php |
275 } |
275 } |
276 else if ( isset($_GET['stage']) && @$_GET['stage'] == 'postpimp' ) |
276 else if ( isset($_GET['stage']) && @$_GET['stage'] == 'postpimp' ) |
277 { |
277 { |
278 // verify version |
278 // verify version |
279 if ( enano_version() != 'upg-' . installer_enano_version() ) |
279 if ( enano_version() != 'upg-' . installer_enano_version() ) |
280 { |
280 { |
281 echo '<p>' . $lang->get('upgrade_err_post_not_available') . '</p>'; |
281 echo '<p>' . $lang->get('upgrade_err_post_not_available') . '</p>'; |
282 $ui->show_footer(); |
282 $ui->show_footer(); |
283 $db->close(); |
283 $db->close(); |
284 exit(); |
284 exit(); |
285 } |
285 } |
286 |
286 |
287 function stg_load_files() |
287 function stg_load_files() |
288 { |
288 { |
289 if ( !@include( ENANO_ROOT . "/install/includes/payload.php" ) ) |
289 if ( !@include( ENANO_ROOT . "/install/includes/payload.php" ) ) |
290 return false; |
290 return false; |
291 |
291 |
292 return true; |
292 return true; |
293 } |
293 } |
294 |
294 |
295 echo '<h3>' . $lang->get('upgrade_post_status_title') . '</h3>'; |
295 echo '<h3>' . $lang->get('upgrade_post_status_title') . '</h3>'; |
296 echo '<p>' . $lang->get('upgrade_post_status_body') . '</p>'; |
296 echo '<p>' . $lang->get('upgrade_post_status_body') . '</p>'; |
297 |
297 |
298 start_install_table(); |
298 start_install_table(); |
299 run_installer_stage('load', $lang->get('install_stg_load_title'), 'stg_load_files', $lang->get('install_stg_load_body'), false); |
299 run_installer_stage('load', $lang->get('install_stg_load_title'), 'stg_load_files', $lang->get('install_stg_load_body'), false); |
300 run_installer_stage('importlang', $lang->get('install_stg_importlang_title'), 'stg_lang_import', $lang->get('install_stg_importlang_body')); |
300 run_installer_stage('importlang', $lang->get('install_stg_importlang_title'), 'stg_lang_import', $lang->get('install_stg_importlang_body')); |
301 run_installer_stage('flushcache', $lang->get('upgrade_stg_flushcache_title'), 'stg_flush_cache', $lang->get('upgrade_stg_flushcache_body')); |
301 run_installer_stage('flushcache', $lang->get('upgrade_stg_flushcache_title'), 'stg_flush_cache', $lang->get('upgrade_stg_flushcache_body')); |
302 run_installer_stage('setversion', $lang->get('upgrade_stg_setversion_title'), 'stg_set_version', $lang->get('upgrade_stg_setversion_body')); |
302 run_installer_stage('setversion', $lang->get('upgrade_stg_setversion_title'), 'stg_set_version', $lang->get('upgrade_stg_setversion_body')); |
303 close_install_table(); |
303 close_install_table(); |
304 |
304 |
305 // demote privileges |
305 // demote privileges |
306 $session->logout(USER_LEVEL_ADMIN); |
306 $session->logout(USER_LEVEL_ADMIN); |
307 |
307 |
308 $link_home = makeUrl(get_main_page(), false, true); |
308 $link_home = makeUrl(get_main_page(), false, true); |
309 echo '<h3>' . $lang->get('upgrade_post_status_finish_title') . '</h3>'; |
309 echo '<h3>' . $lang->get('upgrade_post_status_finish_title') . '</h3>'; |
310 echo '<p>' . $lang->get('upgrade_post_status_finish_body', array('mainpage_link' => $link_home)) . '</p>'; |
310 echo '<p>' . $lang->get('upgrade_post_status_finish_body', array('mainpage_link' => $link_home)) . '</p>'; |
311 } |
311 } |
312 else |
312 else |
313 { |
313 { |
314 ?> |
314 ?> |
315 <h3><?php echo $lang->get('upgrade_confirm_title'); ?></h3> |
315 <h3><?php echo $lang->get('upgrade_confirm_title'); ?></h3> |
316 <p><?php echo $lang->get('upgrade_confirm_body', array('enano_version' => installer_enano_version())); ?></p> |
316 <p><?php echo $lang->get('upgrade_confirm_body', array('enano_version' => installer_enano_version())); ?></p> |
317 <ul> |
317 <ul> |
318 <li><?php echo $lang->get('upgrade_confirm_objective_backup_fs', array('dir' => ENANO_ROOT)); ?></li> |
318 <li><?php echo $lang->get('upgrade_confirm_objective_backup_fs', array('dir' => ENANO_ROOT)); ?></li> |
319 <li><?php echo $lang->get('upgrade_confirm_objective_backup_db', array('dbname' => $dbname)); ?></li> |
319 <li><?php echo $lang->get('upgrade_confirm_objective_backup_db', array('dbname' => $dbname)); ?></li> |
320 </ul> |
320 </ul> |
321 <?php |
321 <?php |
322 if ( $do_langimport && !preg_match('/1\.0/', enano_version()) ): |
322 if ( $do_langimport && !preg_match('/1\.0/', enano_version()) ): |
323 ?> |
323 ?> |
324 <div class="warning-box" style="margin: 10px 0;"> |
324 <div class="warning-box" style="margin: 10px 0;"> |
325 <?php echo $lang->get('upgrade_confirm_warning_langimport'); ?> |
325 <?php echo $lang->get('upgrade_confirm_warning_langimport'); ?> |
326 </div> |
326 </div> |
327 <?php |
327 <?php |
328 endif; |
328 endif; |
329 ?> |
329 ?> |
330 <form method="get" action="upgrade.php" style="text-align: center;"> |
330 <form method="get" action="upgrade.php" style="text-align: center;"> |
331 <input type="hidden" name="auth" value="<?php echo $session->sid_super; ?>" /> |
331 <input type="hidden" name="auth" value="<?php echo $session->sid_super; ?>" /> |
332 <button name="stage" value="pimpmyenano" class="submit" style="padding-bottom: 8px;"> |
332 <button name="stage" value="pimpmyenano" class="submit" style="padding-bottom: 8px;"> |
333 <img src="images/icons/pimp.png" style="position: relative; top: 6px;" /> |
333 <img src="images/icons/pimp.png" style="position: relative; top: 6px;" /> |
334 <?php echo $lang->get('upgrade_confirm_btn_upgrade'); ?> |
334 <?php echo $lang->get('upgrade_confirm_btn_upgrade'); ?> |
335 </button> |
335 </button> |
336 </form> |
336 </form> |
337 <?php |
337 <?php |
338 } |
338 } |
339 |
339 |
340 $ui->show_footer(); |
340 $ui->show_footer(); |
341 |
341 |