move code up one directory
[atutor.git] / install / upgrade.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 // AT_INCLUDE_PATH is the relative path to atutor root include directory
14 // rather than the install include directory because this path is required
15 // by Module.class.php used in ustep3.php.
16 define('AT_INCLUDE_PATH', '../include/');
17
18 if (isset($_POST['new_version'])) {
19         $new_version = $_POST['new_version'];
20 }
21
22 if (isset($_POST['step'])) {
23         $step = intval($_POST['step']);
24 }
25
26 if (!isset($step) || ($step == 0)) {
27         $step = 1;
28 }
29
30 // Be careful at modifying AT_UPGRADE_INCLUDE_PATH constant which is used by 
31 // get_atutor_installation_path() @ common.inc.php in ustep3.php. Must make sure the 
32 // function doesn't get broken at modifying this constant.
33 define('AT_UPGRADE_INCLUDE_PATH', 'include/');
34 require(AT_UPGRADE_INCLUDE_PATH.'common.inc.php');
35
36 if (($step == 2) && isset($_POST['override']) && ($_POST['override'] == 0)) {
37         header('Location: index.php');
38         exit;
39 }
40 session_start();
41 require('include/upgrade_header.php');
42
43 if ($step == 1) {
44         if (!$new_version) {
45                 echo 'You cannot access this page directly. <a href="index.php">Upgrade from here</a> using the <em>Upgrade</em> button.';
46                 require('include/footer.php');
47                 exit;
48         }
49         // in:  select directory
50         // out: confirm verions
51         require('include/ustep1.php');
52 }
53 if ($step == 2) {
54         // in:  update database
55         // out: -
56         require('include/ustep2.php');
57 }
58 if ($step == 3) {
59         // in:  database info
60         // out: convert database from <encoding> to UTF-8
61         require('include/ustep7.php');
62 }
63 if ($step == 4) {
64         // in:  display version specific notices
65         // out: update database with new options
66         require('include/ustep3.php');
67 }
68 if ($step == 5) {
69         // in:  determine where the old content dir is and if it has to be copied
70         // out: try to create the directory and set permissions
71         require('include/step5.php');
72 }
73 if ($step == 6) {
74         // in:  copy the content if needed
75         // out: -
76         require('include/ustep4.php');
77 }
78 if ($step == 7) {
79         // in:  copy the config file
80         // out: -
81         require('include/ustep5.php');
82 }
83 /* anonymous data collection */
84 if ($step == 8) {       
85         require('include/step7.php');
86 }
87
88 if ($step == 9) {
89         require('include/ustep6.php');
90 }
91 require('include/footer.php');
92 ?>