1 |
552
|
thorn
|
<?php
|
2 |
|
|
|
3 |
|
|
// $Id$
|
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 set error
|
34 |
|
|
function set_error($message) {
|
35 |
|
|
global $_POST;
|
36 |
|
|
if(isset($message) AND $message != '') {
|
37 |
|
|
// Copy values entered into session so user doesn't have to re-enter everything
|
38 |
|
|
if(isset($_POST['website_title'])) {
|
39 |
|
|
$_SESSION['wb_url'] = $_POST['wb_url'];
|
40 |
|
|
$_SESSION['wb_path'] = $_POST['wb_path'];
|
41 |
|
|
$_SESSION['default_timezone'] = $_POST['default_timezone'];
|
42 |
|
|
if(!isset($_POST['operating_system'])) {
|
43 |
|
|
$_SESSION['operating_system'] = 'linux';
|
44 |
|
|
} else {
|
45 |
|
|
$_SESSION['operating_system'] = $_POST['operating_system'];
|
46 |
|
|
}
|
47 |
|
|
if(!isset($_POST['world_writeable'])) {
|
48 |
|
|
$_SESSION['world_writeable'] = false;
|
49 |
|
|
} else {
|
50 |
|
|
$_SESSION['world_writeable'] = true;
|
51 |
|
|
}
|
52 |
|
|
$_SESSION['database_host'] = $_POST['database_host'];
|
53 |
|
|
$_SESSION['database_username'] = $_POST['database_username'];
|
54 |
|
|
$_SESSION['database_password'] = $_POST['database_password'];
|
55 |
|
|
$_SESSION['database_name'] = $_POST['database_name'];
|
56 |
|
|
$_SESSION['table_prefix'] = $_POST['table_prefix'];
|
57 |
|
|
if(!isset($_POST['install_tables'])) {
|
58 |
|
|
$_SESSION['install_tables'] = false;
|
59 |
|
|
} else {
|
60 |
|
|
$_SESSION['install_tables'] = true;
|
61 |
|
|
}
|
62 |
|
|
$_SESSION['website_title'] = $_POST['website_title'];
|
63 |
|
|
$_SESSION['admin_username'] = $_POST['admin_username'];
|
64 |
|
|
$_SESSION['admin_email'] = $_POST['admin_email'];
|
65 |
|
|
$_SESSION['admin_password'] = $_POST['admin_password'];
|
66 |
|
|
}
|
67 |
|
|
// Set the message
|
68 |
|
|
$_SESSION['message'] = $message;
|
69 |
|
|
// Specify that session support is enabled
|
70 |
|
|
$_SESSION['session_support'] = '<font class="good">Enabled</font>';
|
71 |
|
|
// Redirect to first page again and exit
|
72 |
|
|
header('Location: index.php?sessions_checked=true');
|
73 |
|
|
exit();
|
74 |
|
|
}
|
75 |
|
|
}
|
76 |
|
|
|
77 |
|
|
// Dummy class to allow modules' install scripts to call $admin->print_error
|
78 |
|
|
class admin_dummy
|
79 |
|
|
{
|
80 |
|
|
var $error='';
|
81 |
|
|
function print_error($message)
|
82 |
|
|
{
|
83 |
|
|
$this->error=$message;
|
84 |
|
|
}
|
85 |
|
|
}
|
86 |
|
|
|
87 |
|
|
// Function to workout what the default permissions are for files created by the webserver
|
88 |
|
|
function default_file_mode($temp_dir) {
|
89 |
|
|
$v = explode(".",PHP_VERSION);
|
90 |
|
|
$v = $v[0].$v[1];
|
91 |
|
|
if($v > 41 AND is_writable($temp_dir)) {
|
92 |
|
|
$filename = $temp_dir.'/test_permissions.txt';
|
93 |
|
|
$handle = fopen($filename, 'w');
|
94 |
|
|
fwrite($handle, 'This file is to get the default file permissions');
|
95 |
|
|
fclose($handle);
|
96 |
|
|
$default_file_mode = '0'.substr(sprintf('%o', fileperms($filename)), -3);
|
97 |
|
|
unlink($filename);
|
98 |
|
|
} else {
|
99 |
|
|
$default_file_mode = '0777';
|
100 |
|
|
}
|
101 |
|
|
return $default_file_mode;
|
102 |
|
|
}
|
103 |
|
|
|
104 |
|
|
// Function to workout what the default permissions are for directories created by the webserver
|
105 |
|
|
function default_dir_mode($temp_dir) {
|
106 |
|
|
$v = explode(".",PHP_VERSION);
|
107 |
|
|
$v = $v[0].$v[1];
|
108 |
|
|
if($v > 41 AND is_writable($temp_dir)) {
|
109 |
|
|
$dirname = $temp_dir.'/test_permissions/';
|
110 |
|
|
mkdir($dirname);
|
111 |
|
|
$default_dir_mode = '0'.substr(sprintf('%o', fileperms($dirname)), -3);
|
112 |
|
|
rmdir($dirname);
|
113 |
|
|
} else {
|
114 |
|
|
$default_dir_mode = '0777';
|
115 |
|
|
}
|
116 |
|
|
return $default_dir_mode;
|
117 |
|
|
}
|
118 |
|
|
|
119 |
|
|
function add_slashes($input) {
|
120 |
|
|
if ( get_magic_quotes_gpc() || ( !is_string($input) ) ) {
|
121 |
|
|
return $input;
|
122 |
|
|
}
|
123 |
|
|
$output = addslashes($input);
|
124 |
|
|
return $output;
|
125 |
|
|
}
|
126 |
|
|
|
127 |
|
|
// Begin check to see if form was even submitted
|
128 |
|
|
// Set error if no post vars found
|
129 |
|
|
if(!isset($_POST['website_title'])) {
|
130 |
|
|
set_error('Please fill-in the form below');
|
131 |
|
|
}
|
132 |
|
|
// End check to see if form was even submitted
|
133 |
|
|
|
134 |
|
|
// Begin path and timezone details code
|
135 |
|
|
|
136 |
|
|
// Check if user has entered the installation url
|
137 |
|
|
if(!isset($_POST['wb_url']) OR $_POST['wb_url'] == '') {
|
138 |
|
|
set_error('Please enter an absolute URL');
|
139 |
|
|
} else {
|
140 |
|
|
$wb_url = $_POST['wb_url'];
|
141 |
|
|
}
|
142 |
|
|
// Remove any slashes at the end of the URL
|
143 |
|
|
if(substr($wb_url, strlen($wb_url)-1, 1) == "/") {
|
144 |
|
|
$wb_url = substr($wb_url, 0, strlen($wb_url)-1);
|
145 |
|
|
}
|
146 |
|
|
if(substr($wb_url, strlen($wb_url)-1, 1) == "\\") {
|
147 |
|
|
$wb_url = substr($wb_url, 0, strlen($wb_url)-1);
|
148 |
|
|
}
|
149 |
|
|
if(substr($wb_url, strlen($wb_url)-1, 1) == "/") {
|
150 |
|
|
$wb_url = substr($wb_url, 0, strlen($wb_url)-1);
|
151 |
|
|
}
|
152 |
|
|
if(substr($wb_url, strlen($wb_url)-1, 1) == "\\") {
|
153 |
|
|
$wb_url = substr($wb_url, 0, strlen($wb_url)-1);
|
154 |
|
|
}
|
155 |
|
|
// Get the default time zone
|
156 |
|
|
if(!isset($_POST['default_timezone']) OR !is_numeric($_POST['default_timezone'])) {
|
157 |
|
|
set_error('Please select a valid default timezone');
|
158 |
|
|
} else {
|
159 |
|
|
$default_timezone = $_POST['default_timezone']*60*60;
|
160 |
|
|
}
|
161 |
|
|
// End path and timezone details code
|
162 |
|
|
|
163 |
|
|
// Begin operating system specific code
|
164 |
|
|
// Get operating system
|
165 |
|
|
if(!isset($_POST['operating_system']) OR $_POST['operating_system'] != 'linux' AND $_POST['operating_system'] != 'windows') {
|
166 |
|
|
set_error('Please select a valid operating system');
|
167 |
|
|
} else {
|
168 |
|
|
$operating_system = $_POST['operating_system'];
|
169 |
|
|
}
|
170 |
|
|
// Work-out file permissions
|
171 |
|
|
if($operating_system == 'windows') {
|
172 |
|
|
$file_mode = '0777';
|
173 |
|
|
$dir_mode = '0777';
|
174 |
|
|
} elseif(isset($_POST['world_writeable']) AND $_POST['world_writeable'] == 'true') {
|
175 |
|
|
$file_mode = '0777';
|
176 |
|
|
$dir_mode = '0777';
|
177 |
|
|
} else {
|
178 |
|
|
$file_mode = default_file_mode('../temp');
|
179 |
|
|
$dir_mode = default_dir_mode('../temp');
|
180 |
|
|
}
|
181 |
|
|
// End operating system specific code
|
182 |
|
|
|
183 |
|
|
// Begin database details code
|
184 |
|
|
// Check if user has entered a database host
|
185 |
|
|
if(!isset($_POST['database_host']) OR $_POST['database_host'] == '') {
|
186 |
|
|
set_error('Please enter a database host name');
|
187 |
|
|
} else {
|
188 |
|
|
$database_host = $_POST['database_host'];
|
189 |
|
|
}
|
190 |
|
|
// Check if user has entered a database username
|
191 |
|
|
if(!isset($_POST['database_username']) OR $_POST['database_username'] == '') {
|
192 |
|
|
set_error('Please enter a database username');
|
193 |
|
|
} else {
|
194 |
|
|
$database_username = $_POST['database_username'];
|
195 |
|
|
}
|
196 |
|
|
// Check if user has entered a database password
|
197 |
|
|
if(!isset($_POST['database_password'])) {
|
198 |
|
|
set_error('Please enter a database password');
|
199 |
|
|
} else {
|
200 |
|
|
$database_password = $_POST['database_password'];
|
201 |
|
|
}
|
202 |
|
|
// Check if user has entered a database name
|
203 |
|
|
if(!isset($_POST['database_name']) OR $_POST['database_name'] == '') {
|
204 |
|
|
set_error('Please enter a database name');
|
205 |
|
|
} else {
|
206 |
|
|
$database_name = $_POST['database_name'];
|
207 |
|
|
}
|
208 |
|
|
// Get table prefix
|
209 |
|
|
$table_prefix = $_POST['table_prefix'];
|
210 |
|
|
// Find out if the user wants to install tables and data
|
211 |
|
|
if(isset($_POST['install_tables']) AND $_POST['install_tables'] == 'true') {
|
212 |
|
|
$install_tables = true;
|
213 |
|
|
} else {
|
214 |
|
|
$install_tables = false;
|
215 |
|
|
}
|
216 |
|
|
// End database details code
|
217 |
|
|
|
218 |
|
|
// Begin website title code
|
219 |
|
|
// Get website title
|
220 |
|
|
if(!isset($_POST['website_title']) OR $_POST['website_title'] == '') {
|
221 |
|
|
set_error('Please enter a website title');
|
222 |
|
|
} else {
|
223 |
|
|
$website_title = add_slashes($_POST['website_title']);
|
224 |
|
|
}
|
225 |
|
|
// End website title code
|
226 |
|
|
|
227 |
|
|
// Begin admin user details code
|
228 |
|
|
// Get admin username
|
229 |
|
|
if(!isset($_POST['admin_username']) OR $_POST['admin_username'] == '') {
|
230 |
|
|
set_error('Please enter a username for the Administrator account');
|
231 |
|
|
} else {
|
232 |
|
|
$admin_username = $_POST['admin_username'];
|
233 |
|
|
}
|
234 |
|
|
// Get admin email and validate it
|
235 |
|
|
if(!isset($_POST['admin_email']) OR $_POST['admin_email'] == '') {
|
236 |
|
|
set_error('Please enter an email for the Administrator account');
|
237 |
|
|
} else {
|
238 |
|
|
if(eregi("^([0-9a-zA-Z]+[-._+&])*[0-9a-zA-Z]+@([-0-9a-zA-Z]+[.])+[a-zA-Z]{2,6}$", $_POST['admin_email'])) {
|
239 |
|
|
$admin_email = $_POST['admin_email'];
|
240 |
|
|
} else {
|
241 |
|
|
set_error('Please enter a valid email address for the Administrator account');
|
242 |
|
|
}
|
243 |
|
|
}
|
244 |
|
|
// Get the two admin passwords entered, and check that they match
|
245 |
|
|
if(!isset($_POST['admin_password']) OR $_POST['admin_password'] == '') {
|
246 |
|
|
set_error('Please enter a password for the Administrator account');
|
247 |
|
|
} else {
|
248 |
|
|
$admin_password = $_POST['admin_password'];
|
249 |
|
|
}
|
250 |
|
|
if(!isset($_POST['admin_repassword']) OR $_POST['admin_repassword'] == '') {
|
251 |
|
|
set_error('Please make sure you re-enter the password for the Administrator account');
|
252 |
|
|
} else {
|
253 |
|
|
$admin_repassword = $_POST['admin_repassword'];
|
254 |
|
|
}
|
255 |
|
|
if($admin_password != $admin_repassword) {
|
256 |
|
|
set_error('Sorry, the two Administrator account passwords you entered do not match');
|
257 |
|
|
}
|
258 |
|
|
// End admin user details code
|
259 |
|
|
|
260 |
|
|
// Try and write settings to config file
|
261 |
|
|
$config_content = "" .
|
262 |
|
|
"<?php\n".
|
263 |
|
|
"\n".
|
264 |
|
|
"define('DB_TYPE', 'mysql');\n".
|
265 |
|
|
"define('DB_HOST', '$database_host');\n".
|
266 |
|
|
"define('DB_USERNAME', '$database_username');\n".
|
267 |
|
|
"define('DB_PASSWORD', '$database_password');\n".
|
268 |
|
|
"define('DB_NAME', '$database_name');\n".
|
269 |
|
|
"define('TABLE_PREFIX', '$table_prefix');\n".
|
270 |
|
|
"\n".
|
271 |
|
|
"define('WB_PATH', dirname(__FILE__));\n".
|
272 |
|
|
"define('WB_URL', '$wb_url');\n".
|
273 |
|
|
"define('ADMIN_PATH', WB_PATH.'/admin');\n".
|
274 |
|
|
"define('ADMIN_URL', '$wb_url/admin');\n".
|
275 |
|
|
"\n".
|
276 |
|
|
"require_once(WB_PATH.'/framework/initialize.php');\n".
|
277 |
|
|
"\n".
|
278 |
|
|
"?>";
|
279 |
|
|
|
280 |
|
|
$config_filename = '../config.php';
|
281 |
|
|
|
282 |
|
|
// Check if the file exists and is writable first.
|
283 |
|
|
if(file_exists($config_filename) AND is_writable($config_filename)) {
|
284 |
|
|
if(!$handle = fopen($config_filename, 'w')) {
|
285 |
|
|
set_error("Cannot open the configuration file ($config_filename)");
|
286 |
|
|
} else {
|
287 |
|
|
if (fwrite($handle, $config_content) === FALSE) {
|
288 |
|
|
set_error("Cannot write to the configuration file ($config_filename)");
|
289 |
|
|
}
|
290 |
|
|
// Close file
|
291 |
|
|
fclose($handle);
|
292 |
|
|
}
|
293 |
|
|
} else {
|
294 |
|
|
set_error("The configuration file $config_filename is not writable. Change its permissions so it is, then re-run step 4.");
|
295 |
|
|
}
|
296 |
|
|
|
297 |
|
|
// Define configuration vars
|
298 |
|
|
define('DB_TYPE', 'mysql');
|
299 |
|
|
define('DB_HOST', $database_host);
|
300 |
|
|
define('DB_USERNAME', $database_username);
|
301 |
|
|
define('DB_PASSWORD', $database_password);
|
302 |
|
|
define('DB_NAME', $database_name);
|
303 |
|
|
define('TABLE_PREFIX', $table_prefix);
|
304 |
|
|
define('WB_PATH', str_replace(array('/install','\install'), '',dirname(__FILE__)));
|
305 |
|
|
define('WB_URL', $wb_url);
|
306 |
|
|
define('ADMIN_PATH', WB_PATH.'/admin');
|
307 |
|
|
define('ADMIN_URL', $wb_url.'/admin');
|
308 |
|
|
|
309 |
|
|
// Check if the user has entered a correct path
|
310 |
|
|
if(!file_exists(WB_PATH.'/framework/class.admin.php')) {
|
311 |
|
|
set_error('It appears the Absolute path that you entered is incorrect');
|
312 |
|
|
}
|
313 |
|
|
|
314 |
|
|
// Try connecting to database
|
315 |
|
|
if(!mysql_connect(DB_HOST, DB_USERNAME, DB_PASSWORD)) {
|
316 |
|
|
set_error('Database host name, username and/or password incorrect. MySQL Error:<br />'.mysql_error());
|
317 |
|
|
}
|
318 |
|
|
|
319 |
|
|
// Try to create the database
|
320 |
|
|
mysql_query('CREATE DATABASE '.$database_name);
|
321 |
|
|
|
322 |
|
|
// Close the mysql connection
|
323 |
|
|
mysql_close();
|
324 |
|
|
|
325 |
|
|
// Include WB functions file
|
326 |
|
|
require_once(WB_PATH.'/framework/functions.php');
|
327 |
|
|
|
328 |
|
|
// Re-connect to the database, this time using in-build database class
|
329 |
|
|
require_once(WB_PATH.'/framework/class.login.php');
|
330 |
|
|
$database=new database();
|
331 |
|
|
|
332 |
|
|
// Check if we should install tables
|
333 |
|
|
if($install_tables == true) {
|
334 |
|
|
|
335 |
|
|
// Remove tables if they exist
|
336 |
|
|
|
337 |
|
|
// Pages table
|
338 |
|
|
$pages = "DROP TABLE IF EXISTS `".TABLE_PREFIX."pages`";
|
339 |
|
|
$database->query($pages);
|
340 |
|
|
// Sections table
|
341 |
|
|
$sections = "DROP TABLE IF EXISTS `".TABLE_PREFIX."sections`";
|
342 |
|
|
$database->query($sections);
|
343 |
|
|
// Settings table
|
344 |
|
|
$settings = "DROP TABLE IF EXISTS `".TABLE_PREFIX."settings`";
|
345 |
|
|
$database->query($settings);
|
346 |
|
|
// Users table
|
347 |
|
|
$users = "DROP TABLE IF EXISTS `".TABLE_PREFIX."users`";
|
348 |
|
|
$database->query($users);
|
349 |
|
|
// Groups table
|
350 |
|
|
$groups = "DROP TABLE IF EXISTS `".TABLE_PREFIX."groups`";
|
351 |
|
|
$database->query($groups);
|
352 |
|
|
// Search table
|
353 |
|
|
$search = "DROP TABLE IF EXISTS `".TABLE_PREFIX."search`";
|
354 |
|
|
$database->query($search);
|
355 |
|
|
// Addons table
|
356 |
|
|
$addons = "DROP TABLE IF EXISTS `".TABLE_PREFIX."addons`";
|
357 |
|
|
$database->query($addons);
|
358 |
|
|
|
359 |
|
|
// Try installing tables
|
360 |
|
|
|
361 |
|
|
// Pages table
|
362 |
|
|
$pages = 'CREATE TABLE `'.TABLE_PREFIX.'pages` ( `page_id` INT NOT NULL auto_increment,'
|
363 |
|
|
. ' `parent` INT NOT NULL DEFAULT \'0\','
|
364 |
|
|
. ' `root_parent` INT NOT NULL DEFAULT \'0\','
|
365 |
|
|
. ' `level` INT NOT NULL DEFAULT \'0\','
|
366 |
|
|
. ' `link` TEXT NOT NULL,'
|
367 |
|
|
. ' `target` VARCHAR( 7 ) NOT NULL DEFAULT \'\' ,'
|
368 |
|
|
. ' `page_title` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
369 |
|
|
. ' `menu_title` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
370 |
|
|
. ' `description` TEXT NOT NULL ,'
|
371 |
|
|
. ' `keywords` TEXT NOT NULL ,'
|
372 |
|
|
. ' `page_trail` TEXT NOT NULL ,'
|
373 |
|
|
. ' `template` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
374 |
|
|
. ' `visibility` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
375 |
|
|
. ' `position` INT NOT NULL DEFAULT \'0\','
|
376 |
|
|
. ' `menu` INT NOT NULL DEFAULT \'0\','
|
377 |
|
|
. ' `language` VARCHAR( 5 ) NOT NULL DEFAULT \'\' ,'
|
378 |
|
|
. ' `searching` INT NOT NULL DEFAULT \'0\','
|
379 |
|
|
. ' `admin_groups` TEXT NOT NULL ,'
|
380 |
|
|
. ' `admin_users` TEXT NOT NULL ,'
|
381 |
|
|
. ' `viewing_groups` TEXT NOT NULL ,'
|
382 |
|
|
. ' `viewing_users` TEXT NOT NULL ,'
|
383 |
|
|
. ' `modified_when` INT NOT NULL DEFAULT \'0\','
|
384 |
|
|
. ' `modified_by` INT NOT NULL DEFAULT \'0\','
|
385 |
|
|
. ' PRIMARY KEY ( `page_id` ) '
|
386 |
|
|
. ' )';
|
387 |
|
|
$database->query($pages);
|
388 |
|
|
|
389 |
|
|
// Sections table
|
390 |
|
|
$pages = 'CREATE TABLE `'.TABLE_PREFIX.'sections` ( `section_id` INT NOT NULL auto_increment,'
|
391 |
|
|
. ' `page_id` INT NOT NULL DEFAULT \'0\','
|
392 |
|
|
. ' `position` INT NOT NULL DEFAULT \'0\','
|
393 |
|
|
. ' `module` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
394 |
|
|
. ' `block` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
395 |
|
|
. ' `publ_start` VARCHAR( 255 ) NOT NULL DEFAULT \'0\' ,'
|
396 |
|
|
. ' `publ_end` VARCHAR( 255 ) NOT NULL DEFAULT \'0\' ,'
|
397 |
|
|
. ' PRIMARY KEY ( `section_id` ) '
|
398 |
|
|
. ' )';
|
399 |
|
|
$database->query($pages);
|
400 |
|
|
|
401 |
|
|
require(WB_PATH.'/admin/interface/version.php');
|
402 |
|
|
|
403 |
|
|
// Settings table
|
404 |
|
|
$settings='CREATE TABLE `'.TABLE_PREFIX.'settings` ( `setting_id` INT NOT NULL auto_increment,'
|
405 |
|
|
. ' `name` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
406 |
|
|
. ' `value` TEXT NOT NULL ,'
|
407 |
|
|
. ' PRIMARY KEY ( `setting_id` ) '
|
408 |
|
|
. ' )';
|
409 |
|
|
$database->query($settings);
|
410 |
|
|
|
411 |
|
|
$settings_rows= "INSERT INTO `".TABLE_PREFIX."settings` "
|
412 |
|
|
." (name, value) VALUES "
|
413 |
|
|
." ('wb_version', '".VERSION."'),"
|
414 |
|
|
." ('website_title', '$website_title'),"
|
415 |
|
|
." ('website_description', ''),"
|
416 |
|
|
." ('website_keywords', ''),"
|
417 |
|
|
." ('website_header', ''),"
|
418 |
|
|
." ('website_footer', ''),"
|
419 |
|
|
." ('wysiwyg_style', 'font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px;'),"
|
420 |
|
|
." ('rename_files_on_upload', 'php,asp,phpx,aspx'),"
|
421 |
|
|
." ('er_level', ''),"
|
422 |
|
|
." ('default_language', 'EN'),"
|
423 |
|
|
." ('app_name', 'wb'),"
|
424 |
|
|
." ('default_timezone', '$default_timezone'),"
|
425 |
|
|
." ('default_date_format', 'M d Y'),"
|
426 |
|
|
." ('default_time_format', 'g:i A'),"
|
427 |
|
|
." ('home_folders', 'true'),"
|
428 |
|
|
." ('default_template', 'round'),"
|
429 |
|
|
." ('default_charset', 'utf-8'),"
|
430 |
|
|
." ('multiple_menus', 'false'),"
|
431 |
|
|
." ('page_level_limit', '4'),"
|
432 |
|
|
." ('intro_page', 'false'),"
|
433 |
|
|
." ('page_trash', 'disabled'),"
|
434 |
|
|
." ('homepage_redirection', 'false'),"
|
435 |
|
|
." ('page_languages', 'false'),"
|
436 |
|
|
." ('wysiwyg_editor', 'fckeditor'),"
|
437 |
|
|
." ('manage_sections', 'true'),"
|
438 |
|
|
." ('section_blocks', 'false'),"
|
439 |
|
|
." ('smart_login', 'false'),"
|
440 |
|
|
." ('captcha_verification', 'true'),"
|
441 |
|
|
." ('frontend_login', 'false'),"
|
442 |
|
|
." ('frontend_signup', 'false'),"
|
443 |
|
|
." ('search', 'public'),"
|
444 |
|
|
." ('page_extension', '.php'),"
|
445 |
|
|
." ('page_spacer', '-'),"
|
446 |
|
|
." ('pages_directory', '/pages'),"
|
447 |
|
|
." ('media_directory', '/media'),"
|
448 |
|
|
." ('operating_system', '$operating_system'),"
|
449 |
|
|
." ('string_file_mode', '$file_mode'),"
|
450 |
|
|
." ('string_dir_mode', '$dir_mode'),"
|
451 |
|
|
." ('wbmailer_routine', 'phpmail'),"
|
452 |
568
|
doc
|
." ('server_email', 'admin@yourdomain.com')," // avoid that mail provider (e.g. mail.com) reject mails like yourname@mail.com
|
453 |
|
|
." ('wbmailer_default_sendername', 'WB Mailer'),"
|
454 |
552
|
thorn
|
." ('wbmailer_smtp_host', ''),"
|
455 |
|
|
." ('wbmailer_smtp_auth', ''),"
|
456 |
|
|
." ('wbmailer_smtp_username', ''),"
|
457 |
|
|
." ('wbmailer_smtp_password', '')";
|
458 |
|
|
$database->query($settings_rows);
|
459 |
|
|
|
460 |
|
|
// Users table
|
461 |
|
|
$users = 'CREATE TABLE `'.TABLE_PREFIX.'users` ( `user_id` INT NOT NULL auto_increment,'
|
462 |
|
|
. ' `group_id` INT NOT NULL DEFAULT \'0\','
|
463 |
|
|
. ' `groups_id` VARCHAR( 255 ) NOT NULL DEFAULT \'0\','
|
464 |
|
|
. ' `active` INT NOT NULL DEFAULT \'0\','
|
465 |
|
|
. ' `username` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
466 |
|
|
. ' `password` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
467 |
|
|
. ' `remember_key` VARCHAR( 255 ) NOT NULL DEFAULT \'\','
|
468 |
|
|
. ' `last_reset` INT NOT NULL DEFAULT \'0\','
|
469 |
|
|
. ' `display_name` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
470 |
|
|
. ' `email` TEXT NOT NULL ,'
|
471 |
|
|
. ' `timezone` INT NOT NULL DEFAULT \'0\','
|
472 |
|
|
. ' `date_format` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
473 |
|
|
. ' `time_format` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
474 |
|
|
. ' `language` VARCHAR( 5 ) NOT NULL DEFAULT \'\' ,'
|
475 |
|
|
. ' `home_folder` TEXT NOT NULL ,'
|
476 |
|
|
. ' `login_when` INT NOT NULL DEFAULT \'0\','
|
477 |
|
|
. ' `login_ip` VARCHAR( 15 ) NOT NULL DEFAULT \'\' ,'
|
478 |
|
|
. ' PRIMARY KEY ( `user_id` ) '
|
479 |
|
|
. ' )';
|
480 |
|
|
$database->query($users);
|
481 |
|
|
|
482 |
|
|
// Groups table
|
483 |
|
|
$groups = 'CREATE TABLE `'.TABLE_PREFIX.'groups` ( `group_id` INT NOT NULL auto_increment,'
|
484 |
|
|
. ' `name` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
485 |
|
|
. ' `system_permissions` TEXT NOT NULL ,'
|
486 |
|
|
. ' `module_permissions` TEXT NOT NULL ,'
|
487 |
|
|
. ' `template_permissions` TEXT NOT NULL ,'
|
488 |
|
|
. ' PRIMARY KEY ( `group_id` ) '
|
489 |
|
|
. ' )';
|
490 |
|
|
$database->query($groups);
|
491 |
|
|
|
492 |
|
|
// Search settings table
|
493 |
|
|
$search = 'CREATE TABLE `'.TABLE_PREFIX.'search` ( `search_id` INT NOT NULL auto_increment,'
|
494 |
|
|
. ' `name` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
495 |
|
|
. ' `value` TEXT NOT NULL ,'
|
496 |
|
|
. ' `extra` TEXT NOT NULL ,'
|
497 |
|
|
. ' PRIMARY KEY ( `search_id` ) '
|
498 |
|
|
. ' )';
|
499 |
|
|
$database->query($search);
|
500 |
|
|
|
501 |
|
|
// Addons table
|
502 |
|
|
$addons = 'CREATE TABLE `'.TABLE_PREFIX.'addons` ( '
|
503 |
|
|
.'`addon_id` INT NOT NULL auto_increment ,'
|
504 |
|
|
.'`type` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
505 |
|
|
.'`directory` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
506 |
|
|
.'`name` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
507 |
|
|
.'`description` TEXT NOT NULL ,'
|
508 |
|
|
.'`function` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
509 |
|
|
.'`version` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
510 |
|
|
.'`platform` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
511 |
|
|
.'`author` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
512 |
|
|
.'`license` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
513 |
|
|
.' PRIMARY KEY ( `addon_id` ) '
|
514 |
|
|
.' )';
|
515 |
|
|
$database->query($addons);
|
516 |
|
|
|
517 |
|
|
// Insert default data
|
518 |
|
|
|
519 |
|
|
// Admin group
|
520 |
|
|
$full_system_permissions = 'pages,pages_view,pages_add,pages_add_l0,pages_settings,pages_modify,pages_intro,pages_delete,media,media_view,media_upload,media_rename,media_delete,media_create,addons,modules,modules_view,modules_install,modules_uninstall,templates,templates_view,templates_install,templates_uninstall,languages,languages_view,languages_install,languages_uninstall,settings,settings_basic,settings_advanced,access,users,users_view,users_add,users_modify,users_delete,groups,groups_view,groups_add,groups_modify,groups_delete,admintools';
|
521 |
|
|
$insert_admin_group = "INSERT INTO `".TABLE_PREFIX."groups` VALUES ('1', 'Administrators', '$full_system_permissions', '', '')";
|
522 |
|
|
$database->query($insert_admin_group);
|
523 |
|
|
// Admin user
|
524 |
|
|
$insert_admin_user = "INSERT INTO `".TABLE_PREFIX."users` (user_id,group_id,groups_id,active,username,password,email,display_name) VALUES ('1','1','1','1','$admin_username','".md5($admin_password)."','$admin_email','Administrator')";
|
525 |
|
|
$database->query($insert_admin_user);
|
526 |
|
|
|
527 |
|
|
// Search header
|
528 |
|
|
$search_header = addslashes('
|
529 |
|
|
<h1>[TEXT_SEARCH]</h1>
|
530 |
|
|
|
531 |
|
|
<form name="search" action="[WB_URL]/search/index.php" method="get">
|
532 |
|
|
<table cellpadding="3" cellspacing="0" border="0" width="500">
|
533 |
|
|
<tr>
|
534 |
|
|
<td>
|
535 |
|
|
<input type="hidden" name="search_path" value="[SEARCH_PATH]" />
|
536 |
|
|
<input type="text" name="string" value="[SEARCH_STRING]" style="width: 100%;" />
|
537 |
|
|
</td>
|
538 |
|
|
<td width="150">
|
539 |
|
|
<input type="submit" value="[TEXT_SEARCH]" style="width: 100%;" />
|
540 |
|
|
</td>
|
541 |
|
|
</tr>
|
542 |
|
|
<tr>
|
543 |
|
|
<td colspan="2">
|
544 |
|
|
<input type="radio" name="match" id="match_all" value="all"[ALL_CHECKED] />
|
545 |
|
|
<label for="match_all">[TEXT_ALL_WORDS]</label>
|
546 |
|
|
<input type="radio" name="match" id="match_any" value="any"[ANY_CHECKED] />
|
547 |
|
|
<label for="match_any">[TEXT_ANY_WORDS]</label>
|
548 |
|
|
<input type="radio" name="match" id="match_exact" value="exact"[EXACT_CHECKED] />
|
549 |
|
|
<label for="match_exact">[TEXT_EXACT_MATCH]</label>
|
550 |
|
|
</td>
|
551 |
|
|
</tr>
|
552 |
|
|
</table>
|
553 |
|
|
|
554 |
|
|
</form>
|
555 |
|
|
|
556 |
|
|
<hr />
|
557 |
|
|
');
|
558 |
|
|
$insert_search_header = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'header', '$search_header', '')";
|
559 |
|
|
$database->query($insert_search_header);
|
560 |
|
|
// Search footer
|
561 |
|
|
$search_footer = addslashes('');
|
562 |
|
|
$insert_search_footer = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'footer', '$search_footer', '')";
|
563 |
|
|
$database->query($insert_search_footer);
|
564 |
|
|
// Search results header
|
565 |
|
|
$search_results_header = addslashes(''.
|
566 |
|
|
'[TEXT_RESULTS_FOR] \'<b>[SEARCH_STRING]</b>\':
|
567 |
|
|
<table cellpadding="2" cellspacing="0" border="0" width="100%" style="padding-top: 10px;">');
|
568 |
|
|
$insert_search_results_header = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'results_header', '$search_results_header', '')";
|
569 |
|
|
$database->query($insert_search_results_header);
|
570 |
|
|
// Search results loop
|
571 |
|
|
$search_results_loop = addslashes(''.
|
572 |
|
|
'<tr style="background-color: #F0F0F0;">
|
573 |
|
|
<td><a href="[LINK]">[TITLE]</a></td>
|
574 |
|
|
<td align="right">[TEXT_LAST_UPDATED_BY] [DISPLAY_NAME] ([USERNAME]) [TEXT_ON] [DATE]</td>
|
575 |
|
|
</tr>
|
576 |
|
|
<tr><td colspan="2" style="text-align: justify; padding-bottom: 5px;">[DESCRIPTION]</td></tr>
|
577 |
|
|
<tr><td colspan="2" style="text-align: justify; padding-bottom: 10px;">[EXCERPT]</td></tr>');
|
578 |
|
|
|
579 |
|
|
$insert_search_results_loop = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'results_loop', '$search_results_loop', '')";
|
580 |
|
|
$database->query($insert_search_results_loop);
|
581 |
|
|
// Search results footer
|
582 |
|
|
$search_results_footer = addslashes("</table>");
|
583 |
|
|
$insert_search_results_footer = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'results_footer', '$search_results_footer', '')";
|
584 |
|
|
$database->query($insert_search_results_footer);
|
585 |
|
|
// Search no results
|
586 |
|
|
$search_no_results = addslashes('<br />[TEXT_NO_RESULTS]');
|
587 |
|
|
$insert_search_no_results = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'no_results', '$search_no_results', '')";
|
588 |
|
|
$database->query($insert_search_no_results);
|
589 |
|
|
// Search module-order
|
590 |
|
|
$search_module_order = addslashes('faqbaker,manual,wysiwyg');
|
591 |
|
|
$insert_search_module_order = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'module_order', '$search_module_order', '')";
|
592 |
|
|
$database->query($insert_search_module_order);
|
593 |
|
|
// Search max lines of excerpt
|
594 |
|
|
$search_max_excerpt = addslashes('15');
|
595 |
|
|
$insert_search_max_excerpt = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'max_excerpt', '$search_max_excerpt', '')";
|
596 |
|
|
$database->query($insert_search_max_excerpt);
|
597 |
|
|
// some config-elements
|
598 |
|
|
$database->query("INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'cfg_enable_old_search', 'true', '')");
|
599 |
|
|
$database->query("INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'cfg_search_keywords', 'true', '')");
|
600 |
|
|
$database->query("INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'cfg_search_description', 'true', '')");
|
601 |
|
|
$database->query("INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'cfg_show_description', 'true', '')");
|
602 |
|
|
// Search template
|
603 |
|
|
$database->query("INSERT INTO `".TABLE_PREFIX."search` (name) VALUES ('template')");
|
604 |
|
|
|
605 |
|
|
require_once(WB_PATH.'/framework/initialize.php');
|
606 |
|
|
|
607 |
|
|
// Include the PclZip class file (thanks to
|
608 |
|
|
require_once(WB_PATH.'/include/pclzip/pclzip.lib.php');
|
609 |
|
|
|
610 |
|
|
// Install add-ons
|
611 |
|
|
if(file_exists(WB_PATH.'/install/modules')) {
|
612 |
|
|
// Unpack pre-packaged modules
|
613 |
|
|
|
614 |
|
|
}
|
615 |
|
|
if(file_exists(WB_PATH.'/install/templates')) {
|
616 |
|
|
// Unpack pre-packaged templates
|
617 |
|
|
|
618 |
|
|
}
|
619 |
|
|
if(file_exists(WB_PATH.'/install/languages')) {
|
620 |
|
|
// Unpack pre-packaged languages
|
621 |
|
|
|
622 |
|
|
}
|
623 |
|
|
|
624 |
|
|
$admin=new admin_dummy();
|
625 |
|
|
// Load addons into DB
|
626 |
|
|
$dirs['modules'] = WB_PATH.'/modules/';
|
627 |
|
|
$dirs['templates'] = WB_PATH.'/templates/';
|
628 |
|
|
$dirs['languages'] = WB_PATH.'/languages/';
|
629 |
|
|
foreach($dirs AS $type => $dir) {
|
630 |
|
|
if($handle = opendir($dir)) {
|
631 |
|
|
while(false !== ($file = readdir($handle))) {
|
632 |
|
|
if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'admin.php' AND $file != 'index.php') {
|
633 |
|
|
// Get addon type
|
634 |
|
|
if($type == 'modules') {
|
635 |
|
|
load_module($dir.'/'.$file, true);
|
636 |
|
|
// Pretty ugly hack to let modules run $admin->set_error
|
637 |
|
|
// See dummy class definition admin_dummy above
|
638 |
|
|
if ($admin->error!='') {
|
639 |
|
|
set_error($admin->error);
|
640 |
|
|
}
|
641 |
|
|
} elseif($type == 'templates') {
|
642 |
|
|
load_template($dir.'/'.$file);
|
643 |
|
|
} elseif($type == 'languages') {
|
644 |
|
|
load_language($dir.'/'.$file);
|
645 |
|
|
}
|
646 |
|
|
}
|
647 |
|
|
}
|
648 |
|
|
closedir($handle);
|
649 |
|
|
}
|
650 |
|
|
}
|
651 |
|
|
|
652 |
|
|
// Check if there was a database error
|
653 |
|
|
if($database->is_error()) {
|
654 |
|
|
set_error($database->get_error());
|
655 |
|
|
}
|
656 |
|
|
|
657 |
|
|
}
|
658 |
|
|
|
659 |
|
|
// Log the user in and go to Website Baker Administration
|
660 |
|
|
$thisApp = new Login(
|
661 |
|
|
array(
|
662 |
|
|
"MAX_ATTEMPS" => "50",
|
663 |
|
|
"WARNING_URL" => ADMIN_URL."/login/warning.html",
|
664 |
|
|
"USERNAME_FIELDNAME" => 'admin_username',
|
665 |
|
|
"PASSWORD_FIELDNAME" => 'admin_password',
|
666 |
|
|
"REMEMBER_ME_OPTION" => SMART_LOGIN,
|
667 |
|
|
"MIN_USERNAME_LEN" => "2",
|
668 |
|
|
"MIN_PASSWORD_LEN" => "2",
|
669 |
|
|
"MAX_USERNAME_LEN" => "30",
|
670 |
|
|
"MAX_PASSWORD_LEN" => "30",
|
671 |
|
|
'LOGIN_URL' => ADMIN_URL."/login/index.php",
|
672 |
|
|
'DEFAULT_URL' => ADMIN_URL."/start/index.php",
|
673 |
|
|
'TEMPLATE_DIR' => ADMIN_PATH."/login",
|
674 |
|
|
'TEMPLATE_FILE' => "template.html",
|
675 |
|
|
'FRONTEND' => false,
|
676 |
|
|
'FORGOTTEN_DETAILS_APP' => ADMIN_URL."/login/forgot/index.php",
|
677 |
|
|
'USERS_TABLE' => TABLE_PREFIX."users",
|
678 |
|
|
'GROUPS_TABLE' => TABLE_PREFIX."groups",
|
679 |
|
|
)
|
680 |
|
|
);
|
681 |
|
|
?>
|