Project

General

Profile

1
<?php
2

    
3
// $Id: index.php 732 2008-03-01 15:17:29Z thorn $
4

    
5
/*
6

    
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2008, Ryan Djurovich
9

    
10
 Website Baker is free software; you can redistribute it and/or modify
11
 it under the terms of the GNU General Public License as published by
12
 the Free Software Foundation; either version 2 of the License, or
13
 (at your option) any later version.
14

    
15
 Website Baker is distributed in the hope that it will be useful,
16
 but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 GNU General Public License for more details.
19

    
20
 You should have received a copy of the GNU General Public License
21
 along with Website Baker; if not, write to the Free Software
22
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23

    
24
*/
25

    
26
// Start a session
27
if(!defined('SESSION_STARTED')) {
28
	session_name('wb_session_id');
29
	session_start();
30
	define('SESSION_STARTED', true);
31
}
32

    
33
// Function to highlight input fields which contain wrong/missing data
34
function field_error($field_name='') {
35
	if(!defined('SESSION_STARTED') || $field_name == '') return;
36
	if(isset($_SESSION['ERROR_FIELD']) && $_SESSION['ERROR_FIELD'] == $field_name) {
37
		return ' class="wrong"';
38
	}
39
}
40

    
41
// Check if the page has been reloaded
42
if(!isset($_GET['sessions_checked']) OR $_GET['sessions_checked'] != 'true') {
43
	// Set session variable
44
	$_SESSION['session_support'] = '<font class="good">Enabled</font>';
45
	// Reload page
46
	header('Location: index.php?sessions_checked=true');
47
	exit(0);
48
} else {
49
	// Check if session variable has been saved after reload
50
	if(isset($_SESSION['session_support'])) {
51
		$session_support = $_SESSION['session_support'];
52
	} else {   
53
		$session_support = '<font class="bad">Disabled</font>';
54
	}
55
}
56

    
57
// Check if AddDefaultCharset is set
58
$e_adc=false;
59
$sapi=php_sapi_name();
60
if(strpos($sapi, 'apache')!==FALSE || strpos($sapi, 'nsapi')!==FALSE) {
61
	flush();
62
	$apache_rheaders=apache_response_headers();
63
	foreach($apache_rheaders AS $h) {
64
		if(strpos($h, 'html; charset')!==FALSE) {
65
			preg_match('/charset\s*=\s*([a-zA-Z0-9- _]+)/', $h, $match);
66
			$apache_charset=$match[1];
67
			$e_adc=$apache_charset;
68
		}
69
	}
70
}
71

    
72
?>
73
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
74
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
75
<head>
76
<title>Website Baker Installation Wizard</title>
77
<link href="stylesheet.css" rel="stylesheet" type="text/css">
78
<script language="javascript" type="text/javascript">
79

    
80
function confirm_link(message, url) {
81
	if(confirm(message)) location.href = url;
82
}
83
function change_os(type) {
84
	if(type == 'linux') {
85
		document.getElementById('operating_system_linux').checked = true;
86
		document.getElementById('operating_system_windows').checked = false;
87
		document.getElementById('file_perms_box').style.display = 'block';
88
	} else if(type == 'windows') {
89
		document.getElementById('operating_system_linux').checked = false;
90
		document.getElementById('operating_system_windows').checked = true;
91
		document.getElementById('file_perms_box').style.display = 'none';
92
	}
93
}
94

    
95
</script>
96
</head>
97
<body>
98

    
99
<table cellpadding="0" cellspacing="0" border="0" width="750" align="center">
100
<tr>
101
	<td width="60" valign="top">
102
		<img src="../admin/interface/logo.png" alt="Logo" />
103
	</td>
104
	<td width="5">&nbsp;</td>
105
	<td style="font-size: 20px;">
106
		<font style="color: #FFFFFF;">Website Baker</font> 
107
		<font style="color: #DDDDDD;">Installation Wizard</font>
108
	</td>
109
</tr>
110
</table>
111

    
112
<form name="website_baker_installation_wizard" action="save.php" method="post">
113
<input type="hidden" name="url" value="" />
114
<input type="hidden" name="username_fieldname" value="admin_username" />
115
<input type="hidden" name="password_fieldname" value="admin_password" />
116
<input type="hidden" name="remember" id="remember" value="true" />
117

    
118
<table cellpadding="0" cellspacing="0" border="0" width="750" align="center" style="margin-top: 10px;">
119
<tr>
120
	<td class="content">
121
	
122
		<center style="padding: 5px;">
123
			Welcome to the Website Baker Installation Wizard.
124
		</center>
125
		
126
		<?php
127
		if(isset($_SESSION['message']) AND $_SESSION['message'] != '') {
128
			?><div style="width: 700px; padding: 10px; margin-bottom: 5px; border: 1px solid #FF0000; background-color: #FFDBDB;"><b>Error:</b> <?php echo $_SESSION['message']; ?></div><?php
129
		}
130
		?>
131
		<table cellpadding="3" cellspacing="0" width="100%" align="center">
132
		<tr>
133
			<td colspan="6"><h1>Step 1</h1>Please check the following requirements are met before continuing...</td>
134
		</tr>
135
		<?php if($session_support != '<font class="good">Enabled</font>') { ?>
136
		<tr>
137
			<td colspan="6" style="font-size: 10px;" class="bad">Please note: PHP Session Support may appear disabled if your browser does not support cookies.</td>
138
		</tr>
139
		<?php } ?>
140
		<tr>
141
			<td width="160" style="color: #666666;">PHP Version > 4.1.0</td>
142
			<td width="60">
143
				<?php
144
				$phpversion = substr(PHP_VERSION, 0, 6);
145
				if($phpversion > 4.1) {
146
					?><font class="good">Yes</font><?php
147
				} else {
148
					?><font class="bad">No</font><?php
149
				}
150
				?>
151
			</td>
152
			<td width="140" style="color: #666666;">PHP Session Support</td>
153
			<td width="105"><?php echo $session_support; ?></td>
154
			<td width="115" style="color: #666666;">PHP Safe Mode</td>
155
			<td>
156
				<?php
157
				if(ini_get('safe_mode')) {
158
					?><font class="bad">Enabled</font><?php
159
				} else {
160
					?><font class="good">Disabled</font><?php
161
				}	
162
				?>
163
			</td>
164
		</tr>
165
		<tr>
166
			<td width="160" style="color: #666666;">AddDefaultCharset unset</td>
167
			<td width="60">
168
				<?php
169
					if($e_adc) {
170
						?><font class="bad">No</font><?php
171
					} else {
172
						?><font class="good">Yes</font><?php
173
					}
174
				?>
175
			</td>
176
			<td colspan="4">&nbsp;</td>
177
		</tr>
178
		<?php if($e_adc) { ?>
179
		<tr>
180
			<td colspan="6" style="font-size: 10px;" class="bad">Please note: AddDefaultCharset is set to <?php echo $e_adc;?> in apache.conf.<br />If you have to use umlauts (e.g. &auml; &aacute;) please change this to Off. - Or use <?php echo $e_adc;?> inside website baker, too.</td>
181
		</tr>
182
		<?php } ?>
183
		</table>
184
		<table cellpadding="3" cellspacing="0" width="100%" align="center">
185
		<tr>
186
			<td colspan="8"><h1>Step 2</h1>Please check the following files/folders are writeable before continuing...</td>
187
		</tr>
188
		<tr>
189
			<td style="color: #666666;">wb/config.php</td>
190
			<td><?php if(is_writable('../config.php')) { echo '<font class="good">Writeable</font>'; } elseif(!file_exists('../config.php')) { echo '<font class="bad">File Not Found</font>'; } else { echo '<font class="bad">Unwriteable</font>'; } ?></td>
191
			<td style="color: #666666;">wb/pages/</td>
192
			<td><?php if(is_writable('../pages/')) { echo '<font class="good">Writeable</font>'; } elseif(!file_exists('../pages/')) { echo '<font class="bad">Directory Not Found</font>'; } else { echo '<font class="bad">Unwriteable</font>'; } ?></td>
193
			<td style="color: #666666;">wb/media/</td>
194
			<td><?php if(is_writable('../media/')) { echo '<font class="good">Writeable</font>'; } elseif(!file_exists('../media/')) { echo '<font class="bad">Directory Not Found</font>'; } else { echo '<font class="bad">Unwriteable</font>'; } ?></td>
195
			<td style="color: #666666;">wb/templates/</td>
196
			<td><?php if(is_writable('../templates/')) { echo '<font class="good">Writeable</font>'; } elseif(!file_exists('../templates/')) { echo '<font class="bad">Directory Not Found</font>'; } else { echo '<font class="bad">Unwriteable</font>'; } ?></td>
197
		</tr>
198
		<tr>
199
			<td style="color: #666666;">wb/modules/</td>
200
			<td><?php if(is_writable('../modules/')) { echo '<font class="good">Writeable</font>'; } elseif(!file_exists('../modules/')) { echo '<font class="bad">Directory Not Found</font>'; } else { echo '<font class="bad">Unwriteable</font>'; } ?></td>
201
			<td style="color: #666666;">wb/languages/</td>
202
			<td><?php if(is_writable('../languages/')) { echo '<font class="good">Writeable</font>'; } elseif(!file_exists('../languages/')) { echo '<font class="bad">Directory Not Found</font>'; } else { echo '<font class="bad">Unwriteable</font>'; } ?></td>
203
			<td style="color: #666666;">wb/temp/</td>
204
			<td><?php if(is_writable('../temp/')) { echo '<font class="good">Writeable</font>'; } elseif(!file_exists('../temp/')) { echo '<font class="bad">Directory Not Found</font>'; } else { echo '<font class="bad">Unwriteable</font>'; } ?></td>
205
			<td>&nbsp;</td>
206
			<td>&nbsp;</td>
207
		</tr>
208
		</table>
209
		<table cellpadding="3" cellspacing="0" width="100%" align="center">
210
		<tr>
211
			<td colspan="2"><h1>Step 3</h1>Please check your path settings, and select a default timezone and a default backend language...</td>
212
		</tr>
213
		<tr>
214
			<td width="125" style="color: #666666;">
215
				Absolute URL:
216
			</td>
217
			<td>
218
				<?php
219
				// Try to guess installation URL
220
				$guessed_url = 'http://'.$_SERVER["SERVER_NAME"].$_SERVER["SCRIPT_NAME"];
221
				$guessed_url = rtrim(dirname($guessed_url), 'install');
222
				?>
223
				<input <?php echo field_error('wb_url');?> type="text" tabindex="1" name="wb_url" style="width: 99%;" value="<?php if(isset($_SESSION['wb_url'])) { echo $_SESSION['wb_url']; } else { echo $guessed_url; } ?>" />
224
			</td>
225
		</tr>
226
		<tr>
227
			<td style="color: #666666;">
228
				Default Timezone:
229
			</td>
230
			<td>
231
				<select <?php echo field_error('default_timezone');?> tabindex="3" name="default_timezone" style="width: 100%;">
232
					<?php
233
					$TIMEZONES['-12'] = 'GMT - 12 Hours';
234
					$TIMEZONES['-11'] = 'GMT -11 Hours';
235
					$TIMEZONES['-10'] = 'GMT -10 Hours';
236
					$TIMEZONES['-9'] = 'GMT -9 Hours';
237
					$TIMEZONES['-8'] = 'GMT -8 Hours';
238
					$TIMEZONES['-7'] = 'GMT -7 Hours';
239
					$TIMEZONES['-6'] = 'GMT -6 Hours';
240
					$TIMEZONES['-5'] = 'GMT -5 Hours';
241
					$TIMEZONES['-4'] = 'GMT -4 Hours';
242
					$TIMEZONES['-3.5'] = 'GMT -3.5 Hours';
243
					$TIMEZONES['-3'] = 'GMT -3 Hours';
244
					$TIMEZONES['-2'] = 'GMT -2 Hours';
245
					$TIMEZONES['-1'] = 'GMT -1 Hour';
246
					$TIMEZONES['0'] = 'GMT';
247
					$TIMEZONES['1'] = 'GMT +1 Hour';
248
					$TIMEZONES['2'] = 'GMT +2 Hours';
249
					$TIMEZONES['3'] = 'GMT +3 Hours';
250
					$TIMEZONES['3.5'] = 'GMT +3.5 Hours';
251
					$TIMEZONES['4'] = 'GMT +4 Hours';
252
					$TIMEZONES['4.5'] = 'GMT +4.5 Hours';
253
					$TIMEZONES['5'] = 'GMT +5 Hours';
254
					$TIMEZONES['5.5'] = 'GMT +5.5 Hours';
255
					$TIMEZONES['6'] = 'GMT +6 Hours';
256
					$TIMEZONES['6.5'] = 'GMT +6.5 Hours';
257
					$TIMEZONES['7'] = 'GMT +7 Hours';
258
					$TIMEZONES['8'] = 'GMT +8 Hours';
259
					$TIMEZONES['9'] = 'GMT +9 Hours';
260
					$TIMEZONES['9.5'] = 'GMT +9.5 Hours';
261
					$TIMEZONES['10'] = 'GMT +10 Hours';
262
					$TIMEZONES['11'] = 'GMT +11 Hours';
263
					$TIMEZONES['12'] = 'GMT +12 Hours';
264
					$TIMEZONES['13'] = 'GMT +13 Hours';
265
					foreach($TIMEZONES AS $hour_offset => $title) {
266
						?>
267
							<option value="<?php echo $hour_offset; ?>"<?php if(isset($_SESSION['default_timezone']) AND $_SESSION['default_timezone'] == $hour_offset) { echo ' selected'; } elseif(!isset($_SESSION['default_timezone']) AND $hour_offset == 0) { echo 'selected'; } ?>><?php echo $title; ?></option>
268
						<?php
269
					}
270
					?>
271
				</select>
272
			</td>
273
		</tr>
274
		<tr>
275
			<td style="color: #666666;">
276
				Default Language:
277
			</td>
278
			<td>
279
				<select <?php echo field_error('default_language');?> tabindex="3" name="default_language" style="width: 100%;">
280
					<?php
281
					$DEFAULT_LANGUAGE = array(
282
						'BG'=>'Bulgarian', 'CA'=>'Catalan', 'CS'=>'&#268;e&scaron;tina', 'DA'=>'Danish', 'DE'=>'Deutsch', 'EN'=>'English',
283
						'ES'=>'Spanish', 'ET'=>'Eesti', 'FI'=>'Suomi', 'FR'=>'Fran&ccedil;ais',
284
						'HR'=>'Hrvatski', 'HU'=>'Magyar','IT'=>'Italiano', 'LV'=>'Latviesu',
285
						'NL'=>'Nederlands','PL'=>'Polski','PT'=>'Portuguese (Brazil)','RU'=>'Russian','SE'=>'Svenska', 'TR'=>'Turkish'
286
					);
287
					foreach($DEFAULT_LANGUAGE as $lang_id => $lang_title) {
288
						?>
289
							<option value="<?php echo $lang_id; ?>"<?php if(isset($_SESSION['default_language']) AND $_SESSION['default_language'] == $lang_id) { echo ' selected'; } elseif(!isset($_SESSION['default_language']) AND $lang_id == 'EN') { echo 'selected'; } ?>><?php echo $lang_title; ?></option>
290
						<?php
291
					}
292
					?>
293
				</select>
294
			</td>
295
		</tr>
296
		</table>
297
		<table cellpadding="5" cellspacing="0" width="100%" align="center">
298
		<tr>
299
			<td colspan="3"><h1>Step 4</h1>Please specify your operating system information below...</td>
300
		</tr>
301
		<tr height="50">
302
			<td width="170">
303
				Server Operating System:
304
			</td>
305
			<td width="180">
306
				<input type="radio" tabindex="4" name="operating_system" id="operating_system_linux" onclick="document.getElementById('file_perms_box').style.display = 'block';" value="linux"<?php if(!isset($_SESSION['operating_system']) OR $_SESSION['operating_system'] == 'linux') { echo ' checked'; } ?> />
307
				<font style="cursor: pointer;" onclick="javascript: change_os('linux');">Linux/Unix based</font>
308
				<br />
309
				<input type="radio" tabindex="5" name="operating_system" id="operating_system_windows" onclick="document.getElementById('file_perms_box').style.display = 'none';" value="windows"<?php if(isset($_SESSION['operating_system']) AND $_SESSION['operating_system'] == 'windows') { echo ' checked'; } ?> />
310
				<font style="cursor: pointer;" onclick="javascript: change_os('windows');">Windows</font>
311
			</td>
312
			<td>
313
				<div name="file_perms_box" id="file_perms_box" style="margin: 0; padding: 0; display: <?php if(isset($_SESSION['operating_system']) AND $_SESSION['operating_system'] == 'windows') { echo 'none'; } else { echo 'block'; } ?>;">
314
					<input type="checkbox" tabindex="6" name="world_writeable" id="world_writeable" value="true"<?php if(isset($_SESSION['world_writeable']) AND $_SESSION['world_writeable'] == true) { echo 'checked'; } ?> />
315
					<label for="world_writeable">
316
						World-writeable file permissions (777)
317
					</label>
318
					<br />
319
					<font class="note">(Please note: only recommended for testing environments)</font>
320
				</div>
321
			</td>
322
		</tr>
323
		</table>
324
		<table cellpadding="5" cellspacing="0" width="100%" align="center">
325
		<tr>
326
			<td colspan="5">Please enter your MySQL database server details below...</td>
327
		</tr>
328
		<tr>
329
			<td width="120" style="color: #666666;">Host Name:</td>
330
			<td width="230">
331
				<input <?php echo field_error('database_host');?> type="text" tabindex="7" name="database_host" style="width: 98%;" value="<?php if(isset($_SESSION['database_host'])) { echo $_SESSION['database_host']; } else { echo 'localhost'; } ?>" />
332
			</td>
333
			<td width="7">&nbsp;</td>
334
			<td width="70" style="color: #666666;">Username:</td>
335
			<td>
336
				<input <?php echo field_error('database_username');?> type="text" tabindex="9" name="database_username" style="width: 98%;" value="<?php if(isset($_SESSION['database_username'])) { echo $_SESSION['database_username']; } else { echo 'root'; } ?>" />
337
			</td>
338
		</tr>
339
		<tr>
340
			<td style="color: #666666;">Database Name:<br />[a-zA-Z0-9_]</td>
341
			<td>
342
				<input <?php echo field_error('database_name');?> type="text" tabindex="8" name="database_name" style="width: 98%;" value="<?php if(isset($_SESSION['database_name'])) { echo $_SESSION['database_name']; } else { echo 'wb'; } ?>" />
343
			</td>
344
			<td>&nbsp;</td>
345
			<td style="color: #666666;">Password:</td>
346
			<td>
347
				<input type="password" tabindex="10" name="database_password" style="width: 98%;"<?php if(isset($_SESSION['database_password'])) { echo ' value = "'.$_SESSION['database_password'].'"'; } ?> />
348
			</td>
349
		</tr>
350
		<tr>
351
			<td style="color: #666666;">Table Prefix:<br />[a-zA-Z0-9_]</td>
352
			<td>
353
				<input <?php echo field_error('table_prefix');?> type="text" tabindex="11" name="table_prefix" style="width: 250px;"<?php if(isset($_SESSION['table_prefix'])) { echo ' value = "'.$_SESSION['table_prefix'].'"'; } ?> />
354
			</td>
355
			<td>&nbsp;</td>
356
			<td colspan="2">
357
				<input type="checkbox" tabindex="12" name="install_tables" id="install_tables" value="true"<?php if(!isset($_SESSION['install_tables'])) { echo ' checked'; } elseif($_SESSION['install_tables'] == 'true') { echo ' checked'; } ?> />
358
				<label for="install_tables" style="color: #666666;">Install Tables</label>
359
				<br />
360
				<span style="font-size: 10px; color: #666666;">(Please note: May remove existing tables and data)</span></td>		
361
			</td>
362
		</tr>
363
		<tr>
364
			<td colspan="5"><h1>Step 5</h1>Please enter your website title below...</td>
365
		</tr>
366
		<tr>
367
			<td style="color: #666666;" colspan="1">Website Title:</td>
368
			<td colspan="4">
369
				<input <?php echo field_error('website_title');?> type="text" tabindex="13" name="website_title" style="width: 99%;" value="<?php if(isset($_SESSION['website_title'])) { echo $_SESSION['website_title']; } ?>" />
370
			</td>
371
		</tr>
372
		<tr>
373
			<td colspan="5"><h1>Step 6</h1>Please enter your Administrator account details below...</td>
374
		</tr>
375
		<tr>
376
			<td style="color: #666666;">Username:</td>
377
			<td>
378
				<input <?php echo field_error('admin_username');?> type="text" tabindex="14" name="admin_username" style="width: 98%;" value="<?php if(isset($_SESSION['admin_username'])) { echo $_SESSION['admin_username']; } else { echo 'admin'; } ?>" />
379
			</td>
380
			<td>&nbsp;</td>
381
			<td style="color: #666666;">Password:</td>
382
			<td>
383
				<input <?php echo field_error('admin_password');?> type="password" tabindex="16" name="admin_password" style="width: 98%;"<?php if(isset($_SESSION['admin_password'])) { echo ' value = "'.$_SESSION['admin_password'].'"'; } ?> />
384
			</td>
385
		</tr>
386
		<tr>
387
			<td style="color: #666666;">Email:</td>
388
			<td>
389
				<input <?php echo field_error('admin_email');?> type="text" tabindex="15" name="admin_email" style="width: 98%;"<?php if(isset($_SESSION['admin_email'])) { echo ' value = "'.$_SESSION['admin_email'].'"'; } ?> />
390
			</td>
391
			<td>&nbsp;</td>
392
			<td style="color: #666666;">Re-Password:</td>
393
			<td>
394
				<input <?php echo field_error('admin_repassword');?> type="password" tabindex="17" name="admin_repassword" style="width: 98%;"<?php if(isset($_SESSION['admin_repassword'])) { echo ' value = "'.$_SESSION['admin_repassword'].'"'; } ?> />
395
			</td>
396
		</tr>
397
		<tr>
398
			<td colspan="5" style="padding: 10px; padding-bottom: 0;"><h1 style="font-size: 0px;">&nbsp;</h1></td>
399
		</tr>
400
		<tr>
401
			<td colspan="4">
402
				<table cellpadding="0" cellspacing="0" width="100%" border="0">
403
				<tr valign="top">
404
					<td>Please note: &nbsp;</td>
405
					<td>
406
						Website Baker is released under the 
407
						<a href="http://www.gnu.org/licenses/gpl.html" target="_blank" tabindex="19">GNU General Public License</a>
408
						<br />
409
						By clicking install, you are accepting the license.
410
					</td>
411
				</tr>
412
				</table>
413
			</td>
414
			<td colspan="1" align="right">
415
				<input type="submit" tabindex="20" name="submit" value="Install Website Baker" class="submit" />
416
			</td>
417
		</tr>
418
		</table>
419
	</td>
420
</tr>
421
</table>
422

    
423
</form>
424

    
425
<table cellpadding="0" cellspacing="0" border="0" width="100%" style="padding: 10px 0px 10px 0px;">
426
<tr>
427
	<td align="center" style="font-size: 10px;">
428
		<!-- Please note: the below reference to the GNU GPL should not be removed, as it provides a link for users to read about warranty, etc. -->
429
		<a href="http://www.websitebaker.org/" style="color: #000000;" target="_blank">Website Baker</a>
430
		is	released under the
431
		<a href="http://www.gnu.org/licenses/gpl.html" style="color: #000000;" target="_blank">GNU General Public License</a>
432
		<!-- Please note: the above reference to the GNU GPL should not be removed, as it provides a link for users to read about warranty, etc. -->
433
	</td>
434
</tr>
435
</table>
436

    
437
</body>
438
</html>
(1-1/3)