~xibo-maintainers/xibo/tempel

« back to all changes in this revision

Viewing changes to install.php

  • Committer: Dan Garner
  • Date: 2015-03-26 14:08:33 UTC
  • Revision ID: git-v1:70d14044444f8dc5d602b99890d59dea46d9470c
Moved web servable files to web folder

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
/*
3
 
 * Xibo - Digital Signage - http://www.xibo.org.uk
4
 
 * Copyright (C) 2009-2014 Alex Harrington and Daniel Garner
5
 
 *
6
 
 * This file is part of Xibo.
7
 
 *
8
 
 * Xibo is free software: you can redistribute it and/or modify
9
 
 * it under the terms of the GNU Affero General Public License as published by
10
 
 * the Free Software Foundation, either version 3 of the License, or
11
 
 * any later version. 
12
 
 *
13
 
 * Xibo is distributed in the hope that it will be useful,
14
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 
 * GNU Affero General Public License for more details.
17
 
 *
18
 
 * You should have received a copy of the GNU Affero General Public License
19
 
 * along with Xibo.  If not, see <http://www.gnu.org/licenses/>.
20
 
 */
21
 
use Xibo\Entity\User;
22
 
use Xibo\Helper\Install;
23
 
use Xibo\Helper\Theme;
24
 
 
25
 
DEFINE('XIBO', true);
26
 
DEFINE('MAX_EXECUTION', true);
27
 
 
28
 
error_reporting(0);
29
 
ini_set('display_errors', 0);
30
 
 
31
 
require_once('lib/app/kit.class.php');
32
 
require_once('config/config.class.php');
33
 
require_once('config/db_config.php');
34
 
require_once("lib/app/app_functions.php");
35
 
require_once('lib/app/debug.class.php');
36
 
require_once("lib/app/pdoconnect.class.php");
37
 
require_once("lib/app/translationengine.class.php");
38
 
require_once("lib/app/thememanager.class.php");
39
 
require_once("lib/app/helpmanager.class.php");
40
 
require_once("lib/app/datemanager.class.php");
41
 
require_once("lib/app/formmanager.class.php");
42
 
require_once("lib/pages/base.class.php");
43
 
require_once('lib/pages/install.class.php');
44
 
require_once("lib/data/data.class.php");
45
 
require_once("lib/modules/module.interface.php");
46
 
require_once("lib/modules/module.class.php");
47
 
require_once("lib/modules/modulefactory.class.php");
48
 
require_once('modules/module_user_general.php');
49
 
 
50
 
// Create a theme
51
 
new Theme(new User(new Database()), 'default');
52
 
Theme::SetPagename('install');
53
 
 
54
 
// Does the settings file exist
55
 
$settingsExists = false;
56
 
 
57
 
if (file_exists('settings.php')) {
58
 
    include_once('settings.php');
59
 
    // Set-up the translations for get text
60
 
    TranslationEngine::InitLocale('en_GB');
61
 
 
62
 
    $settingsExists = true;
63
 
}
64
 
else {
65
 
    TranslationEngine::InitLocale();
66
 
}
67
 
 
68
 
// Define an auto-load function
69
 
spl_autoload_register(function ($class) {
70
 
    \Kit::ClassLoader($class);
71
 
});
72
 
 
73
 
$xibo_step = \Kit::GetParam('step', _REQUEST, _INT, 1);
74
 
 
75
 
$content = '';
76
 
$install = new Install();
77
 
 
78
 
switch ($xibo_step) {
79
 
 
80
 
    case 1:
81
 
        if ($settingsExists)
82
 
            die(__('The CMS has already been installed. Please contact your system administrator.'));
83
 
 
84
 
        // Welcome to the installer (this should only show once)
85
 
        // Checks environment
86
 
        $content = $install->Step1();
87
 
        break;
88
 
 
89
 
    case 2:
90
 
        if ($settingsExists)
91
 
            die(__('The CMS has already been installed. Please contact your system administrator.'));
92
 
 
93
 
        // Collect details about the database
94
 
        $content = $install->Step2();
95
 
        break;
96
 
 
97
 
    case 3:
98
 
        if ($settingsExists)
99
 
            die(__('The CMS has already been installed. Please contact your system administrator.'));
100
 
 
101
 
        // Check and validate DB details
102
 
        if (defined('MAX_EXECUTION') && MAX_EXECUTION)
103
 
            set_time_limit(0);
104
 
 
105
 
        try {
106
 
            $install->Step3();
107
 
 
108
 
            // Redirect to step 4
109
 
            header('Location: install.php?step=4');
110
 
        }
111
 
        catch (Exception $e) {
112
 
            $install->errorMessage = $e->getMessage();
113
 
 
114
 
            // Reload step 2
115
 
            $content = $install->Step2();
116
 
        }
117
 
        break;
118
 
 
119
 
    case 4:
120
 
        // DB installed and we are ready to collect some more details
121
 
        // We should get the admin username and password
122
 
        $content = $install->Step4();
123
 
        break;
124
 
 
125
 
    case 5:
126
 
        // Create a user account
127
 
        try {
128
 
            $install->Step5();
129
 
 
130
 
            // Redirect to step 6
131
 
            header('Location: install.php?step=6');
132
 
        }
133
 
        catch (Exception $e) {
134
 
            $install->errorMessage = $e->getMessage();
135
 
 
136
 
            // Reload step 4
137
 
            $content = $install->Step4();
138
 
        }
139
 
        break;
140
 
 
141
 
    case 6:
142
 
        $content = $install->Step6();
143
 
        break;
144
 
 
145
 
    case 7:
146
 
        // Create a user account
147
 
        try {
148
 
            $install->Step7();
149
 
 
150
 
            // Redirect to step 6
151
 
            header('Location: install.php?step=8');
152
 
        }
153
 
        catch (Exception $e) {
154
 
            $install->errorMessage = $e->getMessage();
155
 
 
156
 
            // Reload step 4
157
 
            $content = $install->Step6();
158
 
        }
159
 
        break;
160
 
 
161
 
    case 8:
162
 
        require_once('lib/app/session.class.php');
163
 
        // Create a Session
164
 
        $session = new Session();
165
 
        // Step 8 ends the execution
166
 
        $install->Step8();
167
 
        break;
168
 
}
169
 
 
170
 
Theme::Set('step', $xibo_step);
171
 
Theme::Set('stepContent', $content);
172
 
 
173
 
// Include the header
174
 
$this->getState()->html .= Theme::RenderReturn('install_header');
175
 
$this->getState()->html .= Theme::RenderReturn('install_footer');
176
 
?>