|
1 <?php |
|
2 |
|
3 /* |
|
4 * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between |
|
5 * Version 1.1.1 |
|
6 * Copyright (C) 2006-2007 Dan Fuhry |
|
7 * Installation package |
|
8 * install.php - Main installation interface |
|
9 * |
|
10 * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License |
|
11 * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. |
|
12 * |
|
13 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. |
|
15 */ |
|
16 |
|
17 define('IN_ENANO', 1); |
|
18 // DEFINE THIS BEFORE RELEASE! |
|
19 define('ENANO_DANGEROUS', 1); |
|
20 |
|
21 require_once('includes/common.php'); |
|
22 |
|
23 $stages = array('language', 'license', 'sysreqs', 'database', 'website', 'login', 'confirm', 'install', 'finish'); |
|
24 $stage_ids = array(); |
|
25 |
|
26 if ( isset($_POST['language']) ) |
|
27 { |
|
28 // Include language lib and additional PHP5-only JSON functions |
|
29 require_once( ENANO_ROOT . '/includes/json2.php' ); |
|
30 require_once( ENANO_ROOT . '/includes/lang.php' ); |
|
31 |
|
32 // We have a language ID - init language |
|
33 $lang_id = $_POST['language']; |
|
34 if ( !isset($languages[$lang_id]) ) |
|
35 { |
|
36 die('Invalid language selection - can\'t load metadata'); |
|
37 } |
|
38 |
|
39 $language_dir = $languages[$lang_id]['dir']; |
|
40 |
|
41 // Initialize language support |
|
42 $lang = new Language($lang_id); |
|
43 $lang->load_file(ENANO_ROOT . '/language/' . $language_dir . '/install.json'); |
|
44 $lang_uri = 'install.php?do=lang_js&language=%s'; |
|
45 |
|
46 // Init UI |
|
47 $ui = new Enano_Installer_UI($lang->get('meta_site_name'), false); |
|
48 |
|
49 // Add stages |
|
50 foreach ( $stages as $stage ) |
|
51 { |
|
52 $stage_ids[$stage] = $ui->add_stage($lang->get("{$stage}_modetitle"), true); |
|
53 } |
|
54 |
|
55 // Determine stage |
|
56 if ( isset($_REQUEST['stage']) && isset($stage_ids[$_REQUEST['stage']]) ) |
|
57 { |
|
58 $ui->set_visible_stage($stage_ids[$_REQUEST['stage']]); |
|
59 $stage = $_REQUEST['stage']; |
|
60 } |
|
61 else |
|
62 { |
|
63 $stage = 'license'; |
|
64 } |
|
65 |
|
66 $stage_num = array_search($stage, $stages); |
|
67 if ( $stage_num ) |
|
68 { |
|
69 $stage_num++; |
|
70 $ui->step = $lang->get('meta_step', array('step' => $stage_num, 'title' => $lang->get("{$stage}_modetitle_long"))); |
|
71 } |
|
72 } |
|
73 else |
|
74 { |
|
75 $ui = new Enano_Installer_UI('Enano installation', false); |
|
76 |
|
77 if ( version_compare(PHP_VERSION, '5.0.0', '<') ) |
|
78 { |
|
79 $ui->__construct('Enano installation', false); |
|
80 } |
|
81 |
|
82 $ui->step = 'Step 1: Choose language'; |
|
83 |
|
84 $stage = 'language'; |
|
85 $stage_ids['language'] = $ui->add_stage('Language', true); |
|
86 $stage_ids['license'] = $ui->add_stage('License', true); |
|
87 $stage_ids['sysreqs'] = $ui->add_stage('Requirements', true); |
|
88 $stage_ids['database'] = $ui->add_stage('Database', true); |
|
89 $stage_ids['website'] = $ui->add_stage('Site info', true); |
|
90 $stage_ids['login'] = $ui->add_stage('Admin login', true); |
|
91 $stage_ids['confirm'] = $ui->add_stage('Review', true); |
|
92 $stage_ids['install'] = $ui->add_stage('Install', true); |
|
93 $stage_ids['finish'] = $ui->add_stage('Finish', true); |
|
94 } |
|
95 |
|
96 // If we don't have PHP 5, show a friendly error message and bail out |
|
97 if ( version_compare(PHP_VERSION, '5.0.0', '<') || isset($_GET['debug_warn_php4']) ) |
|
98 { |
|
99 $ui->set_visible_stage( |
|
100 $ui->add_stage('PHP compatibility notice', false) |
|
101 ); |
|
102 $ui->step = ''; |
|
103 $ui->show_header(); |
|
104 |
|
105 // This isn't localized because all localization code is dependent on |
|
106 // PHP 5 (loading lang.php will throw a parser error under PHP4). This |
|
107 // one message probably doesn't need to be localized anyway. |
|
108 |
|
109 ?> |
|
110 <h2 class="heading-error"> |
|
111 Your server doesn't have support for PHP 5. |
|
112 </h2> |
|
113 <p> |
|
114 PHP 5 is the latest version of the language on which Enano was built. Its many new features have been available since early 2004, yet |
|
115 many web hosts have not migrated to it because of the work involved. In 2007, Zend Corporation announced that support for the aging |
|
116 PHP 4.x would be discontinued at the end of the year. An initiative called <a href="http://gophp5.org/">GoPHP5</a> was started to |
|
117 encourage web hosts to migrate to PHP 5. |
|
118 </p> |
|
119 <p> |
|
120 Because of the industry's decision to not support PHP 4 any longer, the Enano team decided that it was time to begin using the powerful |
|
121 features of PHP 5 at the expense of PHP 4 compatibility. Therefore, this version of Enano cannot be installed on your server until it |
|
122 is upgraded to at least PHP 5.0.0, and preferably the latest available version. |
|
123 <!-- No, not even removing the check in this installer script will help. As soon as the PHP4 check is passed, the installer shows the |
|
124 language selection page, after which the language code is loaded. The language code and libjson2 will trigger parse errors under |
|
125 PHP <5.0.0. --> |
|
126 </p> |
|
127 <p> |
|
128 If you need to use Enano but can't upgrade your PHP because you're on a shared or reseller hosting service, you can use the |
|
129 <a href="http://enanocms.org/download?series=1.0">1.0.x series of Enano</a> on your site. While the Enano team attempts to make this |
|
130 older series work on PHP 4, official support is not provided for installations of Enano on PHP 4. |
|
131 </p> |
|
132 <?php |
|
133 |
|
134 $ui->show_footer(); |
|
135 exit(); |
|
136 } |
|
137 |
|
138 if ( isset($_SERVER['PATH_INFO']) && !isset($_GET['str']) && isset($_GET['do']) ) |
|
139 { |
|
140 $_GET['str'] = substr($_SERVER['PATH_INFO'], 1); |
|
141 } |
|
142 |
|
143 if ( isset($_GET['do']) ) |
|
144 { |
|
145 switch ( $_GET['do'] ) |
|
146 { |
|
147 case 'lang_js': |
|
148 if ( !isset($_GET['language']) ) |
|
149 die(); |
|
150 $lang_id = $_GET['language']; |
|
151 header('Content-type: text/javascript'); |
|
152 if ( !isset($languages[$lang_id]) ) |
|
153 { |
|
154 die('// Bad language ID'); |
|
155 } |
|
156 $language_dir = $languages[$lang_id]['dir']; |
|
157 |
|
158 // Include language lib and additional PHP5-only JSON functions |
|
159 require_once( ENANO_ROOT . '/includes/json2.php' ); |
|
160 require_once( ENANO_ROOT . '/includes/lang.php' ); |
|
161 |
|
162 // Initialize language support |
|
163 $lang = new Language($lang_id); |
|
164 $lang->load_file(ENANO_ROOT . '/language/' . $language_dir . '/install.json'); |
|
165 $lang->load_file(ENANO_ROOT . '/language/' . $language_dir . '/core.json'); |
|
166 |
|
167 $time_now = microtime_float(); |
|
168 $test = "if ( typeof(enano_lang) != 'object' ) |
|
169 { |
|
170 var enano_lang = new Object(); |
|
171 var enano_lang_code = new Object(); |
|
172 } |
|
173 |
|
174 enano_lang[{$lang->lang_id}] = " . enano_json_encode($lang->strings) . "; |
|
175 enano_lang_code[{$lang->lang_id}] = '{$lang->lang_code}';"; |
|
176 $time_total = round(microtime_float() - $time_now, 4); |
|
177 echo "// Generated in $time_total seconds\n"; |
|
178 echo $test; |
|
179 |
|
180 exit(); |
|
181 case 'modrewrite_test': |
|
182 // Include language lib and additional PHP5-only JSON functions |
|
183 require_once( ENANO_ROOT . '/includes/json2.php' ); |
|
184 |
|
185 if ( isset($_GET['str']) && in_array($_GET['str'], array('standard', 'shortened', 'rewrite')) ) |
|
186 { |
|
187 echo 'good_' . $_GET['str']; |
|
188 } |
|
189 else |
|
190 { |
|
191 echo 'bad'; |
|
192 } |
|
193 exit(); |
|
194 } |
|
195 } |
|
196 |
|
197 switch ( $stage ) |
|
198 { |
|
199 default: |
|
200 $ui->show_header(); |
|
201 echo '<p>Invalid stage.</p>'; |
|
202 break; |
|
203 case 'language': |
|
204 $ui->show_header(); |
|
205 ?> |
|
206 <h2>Welcome to Enano.</h2> |
|
207 <h3>Bienvenido a Enano / |
|
208 Wilkommen in Enano / |
|
209 Bienvenue à Enano / |
|
210 Benvenuti a Enano / |
|
211 欢迎 Enano / |
|
212 Enano へようこそ。 |
|
213 </h3> |
|
214 <p> |
|
215 <b>Please select a language:</b> / |
|
216 Por favor, seleccione un idioma: / |
|
217 Bitte wählen Sie eine Sprache: / |
|
218 S’il vous plaît choisir une langue: / |
|
219 Selezionare una lingua: / |
|
220 请选择一种语言: / |
|
221 言語を選択してください:</p> |
|
222 <form action="install.php?stage=license" method="post"> |
|
223 <select name="language" style="width: 200px;" tabindex="1"> |
|
224 <?php |
|
225 foreach ( $languages as $code => $meta ) |
|
226 { |
|
227 $sel = ( $code == 'eng' ) ? ' selected="selected"' : ''; |
|
228 echo '<option value="' . $code . '"' . $sel . '>' . $meta['name'] . '</option>'; |
|
229 } |
|
230 ?> |
|
231 </select> |
|
232 <input tabindex="2" type="submit" value=">>" /> |
|
233 </form> |
|
234 <?php |
|
235 break; |
|
236 case 'license': |
|
237 $ui->show_header(); |
|
238 require( ENANO_ROOT . '/includes/wikiformat.php' ); |
|
239 require( ENANO_ROOT . '/install/includes/stages/license.php' ); |
|
240 break; |
|
241 case 'sysreqs': |
|
242 $ui->show_header(); |
|
243 require( ENANO_ROOT . '/install/includes/stages/sysreqs.php' ); |
|
244 break; |
|
245 case 'database': |
|
246 if ( isset($_POST['driver']) && in_array($_POST['driver'], $supported_drivers) ) |
|
247 { |
|
248 // This is SAFE! It's validated against the array in in_array() above. |
|
249 $driver = $_POST['driver']; |
|
250 require( ENANO_ROOT . "/install/includes/stages/database_{$driver}.php" ); |
|
251 } |
|
252 else |
|
253 { |
|
254 $ui->show_header(); |
|
255 // No driver selected - give the DB drive selection page |
|
256 require( ENANO_ROOT . '/install/includes/stages/database.php' ); |
|
257 } |
|
258 break; |
|
259 case 'website': |
|
260 require( ENANO_ROOT . '/install/includes/stages/website.php' ); |
|
261 break; |
|
262 case 'login': |
|
263 require( ENANO_ROOT . '/install/includes/stages/login.php' ); |
|
264 break; |
|
265 case 'confirm': |
|
266 require( ENANO_ROOT . '/install/includes/stages/confirm.php' ); |
|
267 break; |
|
268 case 'install': |
|
269 require( ENANO_ROOT . '/install/includes/stages/install.php' ); |
|
270 break; |
|
271 } |
|
272 |
|
273 $ui->show_footer(); |
|
274 |
|
275 ?> |