Revision 1370
Added by Dietmar almost 14 years ago
save.php | ||
---|---|---|
1 |
<?php |
|
2 |
/** |
|
3 |
* |
|
4 |
* @category backend |
|
5 |
* @package install |
|
6 |
* @author WebsiteBaker Project |
|
7 |
* @copyright 2004-2009, Ryan Djurovich |
|
8 |
* @copyright 2009-2011, Website Baker Org. e.V. |
|
9 |
* @link http://www.websitebaker2.org/ |
|
10 |
* @license http://www.gnu.org/licenses/gpl.html |
|
11 |
* @platform WebsiteBaker 2.8.x |
|
12 |
* @requirements PHP 5.2.2 and higher |
|
13 |
* @version $Id$ |
|
14 |
* @filesource $HeadURL: $ |
|
15 |
* @lastmodified $Date: $ |
|
16 |
* |
|
17 |
*/ |
|
18 |
|
|
19 |
$debug = true; |
|
20 |
|
|
21 |
if (true === $debug) { |
|
22 |
ini_set('display_errors', 1); |
|
23 |
error_reporting(E_ALL); |
|
24 |
} |
|
25 |
// Start a session |
|
26 |
if(!defined('SESSION_STARTED')) { |
|
27 |
session_name('wb_session_id'); |
|
28 |
session_start(); |
|
29 |
define('SESSION_STARTED', true); |
|
30 |
} |
|
31 |
// get random-part for session_name() |
|
32 |
list($usec,$sec) = explode(' ',microtime()); |
|
33 |
srand((float)$sec+((float)$usec*100000)); |
|
34 |
$session_rand = rand(1000,9999); |
|
35 |
|
|
36 |
// Function to set error |
|
37 |
function set_error($message, $field_name = '') { |
|
38 |
global $_POST; |
|
39 |
if(isset($message) AND $message != '') { |
|
40 |
// Copy values entered into session so user doesn't have to re-enter everything |
|
41 |
if(isset($_POST['website_title'])) { |
|
42 |
$_SESSION['wb_url'] = $_POST['wb_url']; |
|
43 |
$_SESSION['default_timezone'] = $_POST['default_timezone']; |
|
44 |
$_SESSION['default_language'] = $_POST['default_language']; |
|
45 |
if(!isset($_POST['operating_system'])) { |
|
46 |
$_SESSION['operating_system'] = 'linux'; |
|
47 |
} else { |
|
48 |
$_SESSION['operating_system'] = $_POST['operating_system']; |
|
49 |
} |
|
50 |
if(!isset($_POST['world_writeable'])) { |
|
51 |
$_SESSION['world_writeable'] = false; |
|
52 |
} else { |
|
53 |
$_SESSION['world_writeable'] = true; |
|
54 |
} |
|
55 |
$_SESSION['database_host'] = $_POST['database_host']; |
|
56 |
$_SESSION['database_username'] = $_POST['database_username']; |
|
57 |
$_SESSION['database_password'] = $_POST['database_password']; |
|
58 |
$_SESSION['database_name'] = $_POST['database_name']; |
|
59 |
$_SESSION['table_prefix'] = $_POST['table_prefix']; |
|
60 |
if(!isset($_POST['install_tables'])) { |
|
61 |
$_SESSION['install_tables'] = false; |
|
62 |
} else { |
|
63 |
$_SESSION['install_tables'] = true; |
|
64 |
} |
|
65 |
$_SESSION['website_title'] = $_POST['website_title']; |
|
66 |
$_SESSION['admin_username'] = $_POST['admin_username']; |
|
67 |
$_SESSION['admin_email'] = $_POST['admin_email']; |
|
68 |
$_SESSION['admin_password'] = $_POST['admin_password']; |
|
69 |
$_SESSION['admin_repassword'] = $_POST['admin_repassword']; |
|
70 |
} |
|
71 |
// Set the message |
|
72 |
$_SESSION['message'] = $message; |
|
73 |
// Set the element(s) to highlight |
|
74 |
if($field_name != '') { |
|
75 |
$_SESSION['ERROR_FIELD'] = $field_name; |
|
76 |
} |
|
77 |
// Specify that session support is enabled |
|
78 |
$_SESSION['session_support'] = '<font class="good">Enabled</font>'; |
|
79 |
// Redirect to first page again and exit |
|
80 |
header('Location: index.php?sessions_checked=true'); |
|
81 |
exit(); |
|
82 |
} |
|
83 |
} |
|
84 |
|
|
85 |
// Dummy class to allow modules' install scripts to call $admin->print_error |
|
86 |
class admin_dummy |
|
87 |
{ |
|
88 |
var $error=''; |
|
89 |
function print_error($message) |
|
90 |
{ |
|
91 |
$this->error=$message; |
|
92 |
} |
|
93 |
} |
|
94 |
|
|
95 |
// Function to workout what the default permissions are for files created by the webserver |
|
96 |
function default_file_mode($temp_dir) { |
|
97 |
$v = explode(".",PHP_VERSION); |
|
98 |
$v = $v[0].$v[1]; |
|
99 |
if($v > 41 AND is_writable($temp_dir)) { |
|
100 |
$filename = $temp_dir.'/test_permissions.txt'; |
|
101 |
$handle = fopen($filename, 'w'); |
|
102 |
fwrite($handle, 'This file is to get the default file permissions'); |
|
103 |
fclose($handle); |
|
104 |
$default_file_mode = '0'.substr(sprintf('%o', fileperms($filename)), -3); |
|
105 |
unlink($filename); |
|
106 |
} else { |
|
107 |
$default_file_mode = '0777'; |
|
108 |
} |
|
109 |
return $default_file_mode; |
|
110 |
} |
|
111 |
|
|
112 |
// Function to workout what the default permissions are for directories created by the webserver |
|
113 |
function default_dir_mode($temp_dir) { |
|
114 |
$v = explode(".",PHP_VERSION); |
|
115 |
$v = $v[0].$v[1]; |
|
116 |
if($v > 41 AND is_writable($temp_dir)) { |
|
117 |
$dirname = $temp_dir.'/test_permissions/'; |
|
118 |
mkdir($dirname); |
|
119 |
$default_dir_mode = '0'.substr(sprintf('%o', fileperms($dirname)), -3); |
|
120 |
rmdir($dirname); |
|
121 |
} else { |
|
122 |
$default_dir_mode = '0777'; |
|
123 |
} |
|
124 |
return $default_dir_mode; |
|
125 |
} |
|
126 |
|
|
127 |
function add_slashes($input) { |
|
128 |
if ( get_magic_quotes_gpc() || ( !is_string($input) ) ) { |
|
129 |
return $input; |
|
130 |
} |
|
131 |
$output = addslashes($input); |
|
132 |
return $output; |
|
133 |
} |
|
134 |
|
|
135 |
// Begin check to see if form was even submitted |
|
136 |
// Set error if no post vars found |
|
137 |
if(!isset($_POST['website_title'])) { |
|
138 |
set_error('Please fill-in the form below'); |
|
139 |
} |
|
140 |
// End check to see if form was even submitted |
|
141 |
|
|
142 |
// Begin path and timezone details code |
|
143 |
|
|
144 |
// Check if user has entered the installation url |
|
145 |
if(!isset($_POST['wb_url']) OR $_POST['wb_url'] == '') { |
|
146 |
set_error('Please enter an absolute URL', 'wb_url'); |
|
147 |
} else { |
|
148 |
$wb_url = $_POST['wb_url']; |
|
149 |
} |
|
150 |
// Remove any slashes at the end of the URL |
|
151 |
if(substr($wb_url, strlen($wb_url)-1, 1) == "/") { |
|
152 |
$wb_url = substr($wb_url, 0, strlen($wb_url)-1); |
|
153 |
} |
|
154 |
if(substr($wb_url, strlen($wb_url)-1, 1) == "\\") { |
|
155 |
$wb_url = substr($wb_url, 0, strlen($wb_url)-1); |
|
156 |
} |
|
157 |
if(substr($wb_url, strlen($wb_url)-1, 1) == "/") { |
|
158 |
$wb_url = substr($wb_url, 0, strlen($wb_url)-1); |
|
159 |
} |
|
160 |
if(substr($wb_url, strlen($wb_url)-1, 1) == "\\") { |
|
161 |
$wb_url = substr($wb_url, 0, strlen($wb_url)-1); |
|
162 |
} |
|
163 |
// Get the default time zone |
|
164 |
if(!isset($_POST['default_timezone']) OR !is_numeric($_POST['default_timezone'])) { |
|
165 |
set_error('Please select a valid default timezone', 'default_timezone'); |
|
166 |
} else { |
|
167 |
$default_timezone = $_POST['default_timezone']*60*60; |
|
168 |
} |
|
169 |
// End path and timezone details code |
|
170 |
|
|
171 |
// Get the default language |
|
172 |
$allowed_languages = array('BG','CA', 'CS', 'DA', 'DE', 'EN', 'ES', 'ET', 'FI', 'FR', 'HR', 'HU', 'IT', 'LV', 'NL', 'NO', 'PL', 'PT', 'RU','SE','SK','TR'); |
|
173 |
if(!isset($_POST['default_language']) OR !in_array($_POST['default_language'], $allowed_languages)) { |
|
174 |
set_error('Please select a valid default backend language','default_language'); |
|
175 |
} else { |
|
176 |
$default_language = $_POST['default_language']; |
|
177 |
// make sure the selected language file exists in the language folder |
|
178 |
if(!file_exists('../languages/' .$default_language .'.php')) { |
|
179 |
set_error('The language file: \'' .$default_language .'.php\' is missing. Upload file to language folder or choose another language','default_language'); |
|
180 |
} |
|
181 |
} |
|
182 |
// End default language details code |
|
183 |
|
|
184 |
// Begin operating system specific code |
|
185 |
// Get operating system |
|
186 |
if(!isset($_POST['operating_system']) OR $_POST['operating_system'] != 'linux' AND $_POST['operating_system'] != 'windows') { |
|
187 |
set_error('Please select a valid operating system'); |
|
188 |
} else { |
|
189 |
$operating_system = $_POST['operating_system']; |
|
190 |
} |
|
191 |
// Work-out file permissions |
|
192 |
if($operating_system == 'windows') { |
|
193 |
$file_mode = '0777'; |
|
194 |
$dir_mode = '0777'; |
|
195 |
} elseif(isset($_POST['world_writeable']) AND $_POST['world_writeable'] == 'true') { |
|
196 |
$file_mode = '0777'; |
|
197 |
$dir_mode = '0777'; |
|
198 |
} else { |
|
199 |
$file_mode = default_file_mode('../temp'); |
|
200 |
$dir_mode = default_dir_mode('../temp'); |
|
201 |
} |
|
202 |
// End operating system specific code |
|
203 |
|
|
204 |
// Begin database details code |
|
205 |
// Check if user has entered a database host |
|
206 |
if(!isset($_POST['database_host']) OR $_POST['database_host'] == '') { |
|
207 |
set_error('Please enter a database host name', 'database_host'); |
|
208 |
} else { |
|
209 |
$database_host = $_POST['database_host']; |
|
210 |
} |
|
211 |
// Check if user has entered a database username |
|
212 |
if(!isset($_POST['database_username']) OR $_POST['database_username'] == '') { |
|
213 |
set_error('Please enter a database username','database_username'); |
|
214 |
} else { |
|
215 |
$database_username = $_POST['database_username']; |
|
216 |
} |
|
217 |
// Check if user has entered a database password |
|
218 |
if(!isset($_POST['database_password'])) { |
|
219 |
set_error('Please enter a database password', 'database_password'); |
|
220 |
} else { |
|
221 |
$database_password = $_POST['database_password']; |
|
222 |
} |
|
223 |
// Check if user has entered a database name |
|
224 |
if(!isset($_POST['database_name']) OR $_POST['database_name'] == '') { |
|
225 |
set_error('Please enter a database name', 'database_name'); |
|
226 |
} else { |
|
227 |
// make sure only allowed characters are specified |
|
228 |
if(preg_match('/[^a-z0-9_-]+/i', $_POST['database_name'])) { |
|
229 |
// contains invalid characters (only a-z, A-Z, 0-9 and _ allowed to avoid problems with table/field names) |
|
230 |
set_error('Only characters a-z, A-Z, 0-9, - and _ allowed in database name.', 'database_name'); |
|
231 |
} |
|
232 |
$database_name = $_POST['database_name']; |
|
233 |
} |
|
234 |
// Get table prefix |
|
235 |
if(preg_match('/[^a-z0-9_]+/i', $_POST['table_prefix'])) { |
|
236 |
// contains invalid characters (only a-z, A-Z, 0-9 and _ allowed to avoid problems with table/field names) |
|
237 |
set_error('Only characters a-z, A-Z, 0-9 and _ allowed in table_prefix.', 'table_prefix'); |
|
238 |
} else { |
|
239 |
$table_prefix = $_POST['table_prefix']; |
|
240 |
} |
|
241 |
|
|
242 |
// Find out if the user wants to install tables and data |
|
243 |
if(isset($_POST['install_tables']) AND $_POST['install_tables'] == 'true') { |
|
244 |
$install_tables = true; |
|
245 |
} else { |
|
246 |
$install_tables = false; |
|
247 |
} |
|
248 |
// End database details code |
|
249 |
|
|
250 |
// Begin website title code |
|
251 |
// Get website title |
|
252 |
if(!isset($_POST['website_title']) OR $_POST['website_title'] == '') { |
|
253 |
set_error('Please enter a website title', 'website_title'); |
|
254 |
} else { |
|
255 |
$website_title = add_slashes($_POST['website_title']); |
|
256 |
} |
|
257 |
// End website title code |
|
258 |
|
|
259 |
// Begin admin user details code |
|
260 |
// Get admin username |
|
261 |
if(!isset($_POST['admin_username']) OR $_POST['admin_username'] == '') { |
|
262 |
set_error('Please enter a username for the Administrator account','admin_username'); |
|
263 |
} else { |
|
264 |
$admin_username = $_POST['admin_username']; |
|
265 |
} |
|
266 |
// Get admin email and validate it |
|
267 |
if(!isset($_POST['admin_email']) OR $_POST['admin_email'] == '') { |
|
268 |
set_error('Please enter an email for the Administrator account','admin_email'); |
|
269 |
} else { |
|
270 |
if(preg_match('/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/i', $_POST['admin_email'])) { |
|
271 |
$admin_email = $_POST['admin_email']; |
|
272 |
} else { |
|
273 |
set_error('Please enter a valid email address for the Administrator account','admin_email'); |
|
274 |
} |
|
275 |
} |
|
276 |
// Get the two admin passwords entered, and check that they match |
|
277 |
if(!isset($_POST['admin_password']) OR $_POST['admin_password'] == '') { |
|
278 |
set_error('Please enter a password for the Administrator account','admin_password'); |
|
279 |
} else { |
|
280 |
$admin_password = $_POST['admin_password']; |
|
281 |
} |
|
282 |
if(!isset($_POST['admin_repassword']) OR $_POST['admin_repassword'] == '') { |
|
283 |
set_error('Please make sure you re-enter the password for the Administrator account','admin_repassword'); |
|
284 |
} else { |
|
285 |
$admin_repassword = $_POST['admin_repassword']; |
|
286 |
} |
|
287 |
if($admin_password != $admin_repassword) { |
|
288 |
set_error('Sorry, the two Administrator account passwords you entered do not match','admin_repassword'); |
|
289 |
} |
|
290 |
// End admin user details code |
|
291 |
|
|
292 |
// Try and write settings to config file |
|
293 |
$config_content = "" . |
|
294 |
"<?php\n". |
|
295 |
"\n". |
|
296 |
"define('DB_TYPE', 'mysql');\n". |
|
297 |
"define('DB_HOST', '$database_host');\n". |
|
298 |
"define('DB_USERNAME', '$database_username');\n". |
|
299 |
"define('DB_PASSWORD', '$database_password');\n". |
|
300 |
"define('DB_NAME', '$database_name');\n". |
|
301 |
"define('TABLE_PREFIX', '$table_prefix');\n". |
|
302 |
"\n". |
|
303 |
"define('WB_PATH', dirname(__FILE__));\n". |
|
304 |
"define('WB_URL', '$wb_url');\n". |
|
305 |
"define('ADMIN_PATH', WB_PATH.'/admin');\n". |
|
306 |
"define('ADMIN_URL', '$wb_url/admin');\n". |
|
307 |
"\n". |
|
308 |
"require_once(WB_PATH.'/framework/initialize.php');\n". |
|
309 |
"\n". |
|
310 |
"?>"; |
|
311 |
|
|
312 |
$config_filename = '../config.php'; |
|
313 |
|
|
314 |
// Check if the file exists and is writable first. |
|
315 |
if(file_exists($config_filename) AND is_writable($config_filename)) { |
|
316 |
if(!$handle = fopen($config_filename, 'w')) { |
|
317 |
set_error("Cannot open the configuration file ($config_filename)"); |
|
318 |
} else { |
|
319 |
if (fwrite($handle, $config_content) === FALSE) { |
|
320 |
set_error("Cannot write to the configuration file ($config_filename)"); |
|
321 |
} |
|
322 |
// Close file |
|
323 |
fclose($handle); |
|
324 |
} |
|
325 |
} else { |
|
326 |
set_error("The configuration file $config_filename is not writable. Change its permissions so it is, then re-run step 4."); |
|
327 |
} |
|
328 |
|
|
329 |
// Define configuration vars |
|
330 |
define('DB_TYPE', 'mysql'); |
|
331 |
define('DB_HOST', $database_host); |
|
332 |
define('DB_USERNAME', $database_username); |
|
333 |
define('DB_PASSWORD', $database_password); |
|
334 |
define('DB_NAME', $database_name); |
|
335 |
define('TABLE_PREFIX', $table_prefix); |
|
336 |
define('WB_PATH', str_replace(array('/install','\install'), '',dirname(__FILE__))); |
|
337 |
define('WB_URL', $wb_url); |
|
338 |
define('ADMIN_PATH', WB_PATH.'/admin'); |
|
339 |
define('ADMIN_URL', $wb_url.'/admin'); |
|
340 |
|
|
341 |
// Check if the user has entered a correct path |
|
342 |
if(!file_exists(WB_PATH.'/framework/class.admin.php')) { |
|
343 |
set_error('It appears the Absolute path that you entered is incorrect'); |
|
344 |
} |
|
345 |
|
|
346 |
// Try connecting to database |
|
347 |
if(!@mysql_connect(DB_HOST, DB_USERNAME, DB_PASSWORD)) { |
|
348 |
set_error('Database host name, username and/or password incorrect. MySQL Error:<br />'.mysql_error()); |
|
349 |
} |
|
350 |
|
|
351 |
// Try to create the database |
|
352 |
mysql_query('CREATE DATABASE `'.$database_name.'`'); |
|
353 |
|
|
354 |
// Close the mysql connection |
|
355 |
mysql_close(); |
|
356 |
|
|
357 |
// Include WB functions file |
|
358 |
require_once(WB_PATH.'/framework/functions.php'); |
|
359 |
|
|
360 |
// Re-connect to the database, this time using in-build database class |
|
361 |
require_once(WB_PATH.'/framework/class.login.php'); |
|
362 |
$database=new database(); |
|
363 |
|
|
364 |
// Check if we should install tables |
|
365 |
if($install_tables == true) { |
|
366 |
if (!defined('WB_INSTALL_PROCESS')) define ('WB_INSTALL_PROCESS', true); |
|
367 |
// Remove tables if they exist |
|
368 |
|
|
369 |
// Pages table |
|
370 |
$pages = "DROP TABLE IF EXISTS `".TABLE_PREFIX."pages`"; |
|
371 |
$database->query($pages); |
|
372 |
// Sections table |
|
373 |
$sections = "DROP TABLE IF EXISTS `".TABLE_PREFIX."sections`"; |
|
374 |
$database->query($sections); |
|
375 |
// Settings table |
|
376 |
$settings = "DROP TABLE IF EXISTS `".TABLE_PREFIX."settings`"; |
|
377 |
$database->query($settings); |
|
378 |
// Users table |
|
379 |
$users = "DROP TABLE IF EXISTS `".TABLE_PREFIX."users`"; |
|
380 |
$database->query($users); |
|
381 |
// Groups table |
|
382 |
$groups = "DROP TABLE IF EXISTS `".TABLE_PREFIX."groups`"; |
|
383 |
$database->query($groups); |
|
384 |
// Search table |
|
385 |
$search = "DROP TABLE IF EXISTS `".TABLE_PREFIX."search`"; |
|
386 |
$database->query($search); |
|
387 |
// Addons table |
|
388 |
$addons = "DROP TABLE IF EXISTS `".TABLE_PREFIX."addons`"; |
|
389 |
$database->query($addons); |
|
390 |
|
|
391 |
// Try installing tables |
|
392 |
|
|
393 |
// Pages table |
|
394 |
$pages = 'CREATE TABLE `'.TABLE_PREFIX.'pages` ( `page_id` INT NOT NULL auto_increment,' |
|
395 |
. ' `parent` INT NOT NULL DEFAULT \'0\',' |
|
396 |
. ' `root_parent` INT NOT NULL DEFAULT \'0\',' |
|
397 |
. ' `level` INT NOT NULL DEFAULT \'0\',' |
|
398 |
. ' `link` TEXT NOT NULL,' |
|
399 |
. ' `target` VARCHAR( 7 ) NOT NULL DEFAULT \'\' ,' |
|
400 |
. ' `page_title` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
401 |
. ' `menu_title` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
402 |
. ' `description` TEXT NOT NULL ,' |
|
403 |
. ' `keywords` TEXT NOT NULL ,' |
|
404 |
. ' `page_trail` TEXT NOT NULL ,' |
|
405 |
. ' `template` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
406 |
. ' `visibility` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
407 |
. ' `position` INT NOT NULL DEFAULT \'0\',' |
|
408 |
. ' `menu` INT NOT NULL DEFAULT \'0\',' |
|
409 |
. ' `language` VARCHAR( 5 ) NOT NULL DEFAULT \'\' ,' |
|
410 |
. ' `searching` INT NOT NULL DEFAULT \'0\',' |
|
411 |
. ' `admin_groups` TEXT NOT NULL ,' |
|
412 |
. ' `admin_users` TEXT NOT NULL ,' |
|
413 |
. ' `viewing_groups` TEXT NOT NULL ,' |
|
414 |
. ' `viewing_users` TEXT NOT NULL ,' |
|
415 |
. ' `modified_when` INT NOT NULL DEFAULT \'0\',' |
|
416 |
. ' `modified_by` INT NOT NULL DEFAULT \'0\',' |
|
417 |
. ' PRIMARY KEY ( `page_id` ) ' |
|
418 |
. ' )'; |
|
419 |
$database->query($pages); |
|
420 |
|
|
421 |
// Sections table |
|
422 |
$pages = 'CREATE TABLE `'.TABLE_PREFIX.'sections` ( `section_id` INT NOT NULL auto_increment,' |
|
423 |
. ' `page_id` INT NOT NULL DEFAULT \'0\',' |
|
424 |
. ' `position` INT NOT NULL DEFAULT \'0\',' |
|
425 |
. ' `module` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
426 |
. ' `block` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
427 |
. ' `publ_start` VARCHAR( 255 ) NOT NULL DEFAULT \'0\' ,' |
|
428 |
. ' `publ_end` VARCHAR( 255 ) NOT NULL DEFAULT \'0\' ,' |
|
429 |
. ' PRIMARY KEY ( `section_id` ) ' |
|
430 |
. ' )'; |
|
431 |
$database->query($pages); |
|
432 |
|
|
433 |
require(ADMIN_PATH.'/interface/version.php'); |
|
434 |
|
|
435 |
// Settings table |
|
436 |
$settings='CREATE TABLE `'.TABLE_PREFIX.'settings` ( `setting_id` INT NOT NULL auto_increment,' |
|
437 |
. ' `name` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
438 |
. ' `value` TEXT NOT NULL ,' |
|
439 |
. ' PRIMARY KEY ( `setting_id` ) ' |
|
440 |
. ' )'; |
|
441 |
$database->query($settings); |
|
442 |
|
|
443 |
$settings_rows= "INSERT INTO `".TABLE_PREFIX."settings` " |
|
444 |
." (name, value) VALUES " |
|
445 |
." ('wb_version', '".VERSION."')," |
|
446 |
." ('website_title', '$website_title')," |
|
447 |
." ('website_description', '')," |
|
448 |
." ('website_keywords', '')," |
|
449 |
." ('website_header', '')," |
|
450 |
." ('website_footer', '')," |
|
451 |
." ('wysiwyg_style', 'font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px;')," |
|
452 |
." ('rename_files_on_upload', 'php,asp,phpx,aspx')," |
|
453 |
." ('er_level', '')," |
|
454 |
." ('default_language', '$default_language')," |
|
455 |
." ('app_name', 'wb_$session_rand')," |
|
456 |
." ('sec_anchor', 'wb_')," |
|
457 |
." ('default_timezone', '$default_timezone')," |
|
458 |
." ('default_date_format', 'M d Y')," |
|
459 |
." ('default_time_format', 'g:i A')," |
|
460 |
." ('redirect_timer', '1500')," |
|
461 |
." ('home_folders', 'true')," |
|
462 |
." ('default_template', 'round')," |
|
463 |
." ('default_theme', 'wb_theme')," |
|
464 |
." ('default_charset', 'utf-8')," |
|
465 |
." ('multiple_menus', 'false')," |
|
466 |
." ('page_level_limit', '4')," |
|
467 |
." ('intro_page', 'false')," |
|
468 |
." ('page_trash', 'disabled')," |
|
469 |
." ('homepage_redirection', 'false')," |
|
470 |
." ('page_languages', 'false')," |
|
471 |
." ('wysiwyg_editor', 'fckeditor')," |
|
472 |
." ('manage_sections', 'true')," |
|
473 |
." ('section_blocks', 'false')," |
|
474 |
." ('smart_login', 'false')," |
|
475 |
." ('frontend_login', 'false')," |
|
476 |
." ('frontend_signup', 'false')," |
|
477 |
." ('search', 'public')," |
|
478 |
." ('page_extension', '.php')," |
|
479 |
." ('page_spacer', '-')," |
|
480 |
." ('pages_directory', '/pages')," |
|
481 |
." ('media_directory', '/media')," |
|
482 |
." ('operating_system', '$operating_system')," |
|
483 |
." ('string_file_mode', '$file_mode')," |
|
484 |
." ('string_dir_mode', '$dir_mode')," |
|
485 |
." ('wbmailer_routine', 'phpmail')," |
|
486 |
." ('server_email', 'admin@yourdomain.com')," // avoid that mail provider (e.g. mail.com) reject mails like yourname@mail.com |
|
487 |
." ('wbmailer_default_sendername', 'WB Mailer')," |
|
488 |
." ('wbmailer_smtp_host', '')," |
|
489 |
." ('wbmailer_smtp_auth', '')," |
|
490 |
." ('wbmailer_smtp_username', '')," |
|
491 |
." ('wbmailer_smtp_password', '')," |
|
492 |
." ('mediasettings', '')"; |
|
493 |
$database->query($settings_rows); |
|
494 |
|
|
495 |
// Users table |
|
496 |
$users = 'CREATE TABLE `'.TABLE_PREFIX.'users` ( `user_id` INT NOT NULL auto_increment,' |
|
497 |
. ' `group_id` INT NOT NULL DEFAULT \'0\',' |
|
498 |
. ' `groups_id` VARCHAR( 255 ) NOT NULL DEFAULT \'0\',' |
|
499 |
. ' `active` INT NOT NULL DEFAULT \'0\',' |
|
500 |
. ' `username` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
501 |
. ' `password` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
502 |
. ' `remember_key` VARCHAR( 255 ) NOT NULL DEFAULT \'\',' |
|
503 |
. ' `last_reset` INT NOT NULL DEFAULT \'0\',' |
|
504 |
. ' `display_name` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
505 |
. ' `email` TEXT NOT NULL ,' |
|
506 |
. ' `timezone` INT NOT NULL DEFAULT \'0\',' |
|
507 |
. ' `date_format` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
508 |
. ' `time_format` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
509 |
. ' `language` VARCHAR( 5 ) NOT NULL DEFAULT \'' .$default_language .'\' ,' |
|
510 |
. ' `home_folder` TEXT NOT NULL ,' |
|
511 |
. ' `login_when` INT NOT NULL DEFAULT \'0\',' |
|
512 |
. ' `login_ip` VARCHAR( 15 ) NOT NULL DEFAULT \'\' ,' |
|
513 |
. ' PRIMARY KEY ( `user_id` ) ' |
|
514 |
. ' )'; |
|
515 |
$database->query($users); |
|
516 |
|
|
517 |
// Groups table |
|
518 |
$groups = 'CREATE TABLE `'.TABLE_PREFIX.'groups` ( `group_id` INT NOT NULL auto_increment,' |
|
519 |
. ' `name` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
520 |
. ' `system_permissions` TEXT NOT NULL ,' |
|
521 |
. ' `module_permissions` TEXT NOT NULL ,' |
|
522 |
. ' `template_permissions` TEXT NOT NULL ,' |
|
523 |
. ' PRIMARY KEY ( `group_id` ) ' |
|
524 |
. ' )'; |
|
525 |
$database->query($groups); |
|
526 |
|
|
527 |
// Search settings table |
|
528 |
$search = 'CREATE TABLE `'.TABLE_PREFIX.'search` ( `search_id` INT NOT NULL auto_increment,' |
|
529 |
. ' `name` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
530 |
. ' `value` TEXT NOT NULL ,' |
|
531 |
. ' `extra` TEXT NOT NULL ,' |
|
532 |
. ' PRIMARY KEY ( `search_id` ) ' |
|
533 |
. ' )'; |
|
534 |
$database->query($search); |
|
535 |
|
|
536 |
// Addons table |
|
537 |
$addons = 'CREATE TABLE `'.TABLE_PREFIX.'addons` ( ' |
|
538 |
.'`addon_id` INT NOT NULL auto_increment ,' |
|
539 |
.'`type` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
540 |
.'`directory` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
541 |
.'`name` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
542 |
.'`description` TEXT NOT NULL ,' |
|
543 |
.'`function` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
544 |
.'`version` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
545 |
.'`platform` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
546 |
.'`author` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
547 |
.'`license` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
548 |
.' PRIMARY KEY ( `addon_id` ) ' |
|
549 |
.' )'; |
|
550 |
$database->query($addons); |
|
551 |
|
|
552 |
// Insert default data |
|
553 |
|
|
554 |
// Admin group |
|
555 |
$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'; |
|
556 |
$insert_admin_group = "INSERT INTO `".TABLE_PREFIX."groups` VALUES ('1', 'Administrators', '$full_system_permissions', '', '')"; |
|
557 |
$database->query($insert_admin_group); |
|
558 |
// Admin user |
|
559 |
$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')"; |
|
560 |
$database->query($insert_admin_user); |
|
561 |
|
|
562 |
// Search header |
|
563 |
$search_header = addslashes(' |
|
564 |
<h1>[TEXT_SEARCH]</h1> |
|
565 |
|
|
566 |
<form name="searchpage" action="[WB_URL]/search/index.php" method="get"> |
|
567 |
<table cellpadding="3" cellspacing="0" border="0" width="500"> |
|
568 |
<tr> |
|
569 |
<td> |
|
570 |
<input type="hidden" name="search_path" value="[SEARCH_PATH]" /> |
|
571 |
<input type="text" name="string" value="[SEARCH_STRING]" style="width: 100%;" /> |
|
572 |
</td> |
|
573 |
<td width="150"> |
|
574 |
<input type="submit" value="[TEXT_SEARCH]" style="width: 100%;" /> |
|
575 |
</td> |
|
576 |
</tr> |
|
577 |
<tr> |
|
578 |
<td colspan="2"> |
|
579 |
<input type="radio" name="match" id="match_all" value="all"[ALL_CHECKED] /> |
|
580 |
<label for="match_all">[TEXT_ALL_WORDS]</label> |
|
581 |
<input type="radio" name="match" id="match_any" value="any"[ANY_CHECKED] /> |
|
582 |
<label for="match_any">[TEXT_ANY_WORDS]</label> |
|
583 |
<input type="radio" name="match" id="match_exact" value="exact"[EXACT_CHECKED] /> |
|
584 |
<label for="match_exact">[TEXT_EXACT_MATCH]</label> |
|
585 |
</td> |
|
586 |
</tr> |
|
587 |
</table> |
|
588 |
|
|
589 |
</form> |
|
590 |
|
|
591 |
<hr /> |
|
592 |
'); |
|
593 |
$insert_search_header = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'header', '$search_header', '')"; |
|
594 |
$database->query($insert_search_header); |
|
595 |
// Search footer |
|
596 |
$search_footer = addslashes(''); |
|
597 |
$insert_search_footer = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'footer', '$search_footer', '')"; |
|
598 |
$database->query($insert_search_footer); |
|
599 |
// Search results header |
|
600 |
$search_results_header = addslashes(''. |
|
601 |
'[TEXT_RESULTS_FOR] \'<b>[SEARCH_STRING]</b>\': |
|
602 |
<table cellpadding="2" cellspacing="0" border="0" width="100%" style="padding-top: 10px;">'); |
|
603 |
$insert_search_results_header = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'results_header', '$search_results_header', '')"; |
|
604 |
$database->query($insert_search_results_header); |
|
605 |
// Search results loop |
|
606 |
$search_results_loop = addslashes(''. |
|
607 |
'<tr style="background-color: #F0F0F0;"> |
|
608 |
<td><a href="[LINK]">[TITLE]</a></td> |
|
609 |
<td align="right">[TEXT_LAST_UPDATED_BY] [DISPLAY_NAME] ([USERNAME]) [TEXT_ON] [DATE]</td> |
|
610 |
</tr> |
|
611 |
<tr><td colspan="2" style="text-align: justify; padding-bottom: 5px;">[DESCRIPTION]</td></tr> |
|
612 |
<tr><td colspan="2" style="text-align: justify; padding-bottom: 10px;">[EXCERPT]</td></tr>'); |
|
613 |
|
|
614 |
$insert_search_results_loop = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'results_loop', '$search_results_loop', '')"; |
|
615 |
$database->query($insert_search_results_loop); |
|
616 |
// Search results footer |
|
617 |
$search_results_footer = addslashes("</table>"); |
|
618 |
$insert_search_results_footer = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'results_footer', '$search_results_footer', '')"; |
|
619 |
$database->query($insert_search_results_footer); |
|
620 |
// Search no results |
|
621 |
$search_no_results = addslashes('<tr><td><p>[TEXT_NO_RESULTS]</p></td></tr>'); |
|
622 |
$insert_search_no_results = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'no_results', '$search_no_results', '')"; |
|
623 |
$database->query($insert_search_no_results); |
|
624 |
// Search module-order |
|
625 |
$search_module_order = addslashes('faqbaker,manual,wysiwyg'); |
|
626 |
$insert_search_module_order = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'module_order', '$search_module_order', '')"; |
|
627 |
$database->query($insert_search_module_order); |
|
628 |
// Search max lines of excerpt |
|
629 |
$search_max_excerpt = addslashes('15'); |
|
630 |
$insert_search_max_excerpt = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'max_excerpt', '$search_max_excerpt', '')"; |
|
631 |
$database->query($insert_search_max_excerpt); |
|
632 |
// max time to search per module |
|
633 |
$search_time_limit = addslashes('0'); |
|
634 |
$insert_search_time_limit = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'time_limit', '$search_time_limit', '')"; |
|
635 |
$database->query($insert_search_time_limit); |
|
636 |
// some config-elements |
|
637 |
$database->query("INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'cfg_enable_old_search', 'true', '')"); |
|
638 |
$database->query("INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'cfg_search_keywords', 'true', '')"); |
|
639 |
$database->query("INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'cfg_search_description', 'true', '')"); |
|
640 |
$database->query("INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'cfg_show_description', 'true', '')"); |
|
641 |
$database->query("INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'cfg_enable_flush', 'false', '')"); |
|
642 |
// Search template |
|
643 |
$database->query("INSERT INTO `".TABLE_PREFIX."search` (name) VALUES ('template')"); |
|
644 |
|
|
645 |
require_once(WB_PATH.'/framework/initialize.php'); |
|
646 |
|
|
647 |
// Include the PclZip class file (thanks to |
|
648 |
require_once(WB_PATH.'/include/pclzip/pclzip.lib.php'); |
|
649 |
|
|
650 |
// Install add-ons |
|
651 |
if(file_exists(WB_PATH.'/install/modules')) { |
|
652 |
// Unpack pre-packaged modules |
|
653 |
|
|
654 |
} |
|
655 |
if(file_exists(WB_PATH.'/install/templates')) { |
|
656 |
// Unpack pre-packaged templates |
|
657 |
|
|
658 |
} |
|
659 |
if(file_exists(WB_PATH.'/install/languages')) { |
|
660 |
// Unpack pre-packaged languages |
|
661 |
|
|
662 |
} |
|
663 |
|
|
664 |
$admin=new admin_dummy(); |
|
665 |
// Load addons into DB |
|
666 |
$dirs['modules'] = WB_PATH.'/modules/'; |
|
667 |
$dirs['templates'] = WB_PATH.'/templates/'; |
|
668 |
$dirs['languages'] = WB_PATH.'/languages/'; |
|
669 |
foreach($dirs AS $type => $dir) { |
|
670 |
if($handle = opendir($dir)) { |
|
671 |
while(false !== ($file = readdir($handle))) { |
|
672 |
if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'admin.php' AND $file != 'index.php') { |
|
673 |
// Get addon type |
|
674 |
if($type == 'modules') { |
|
675 |
load_module($dir.'/'.$file, true); |
|
676 |
// Pretty ugly hack to let modules run $admin->set_error |
|
677 |
// See dummy class definition admin_dummy above |
|
678 |
if ($admin->error!='') { |
|
679 |
set_error($admin->error); |
|
680 |
} |
|
681 |
} elseif($type == 'templates') { |
|
682 |
load_template($dir.'/'.$file); |
|
683 |
} elseif($type == 'languages') { |
|
684 |
load_language($dir.'/'.$file); |
|
685 |
} |
|
686 |
} |
|
687 |
} |
|
688 |
closedir($handle); |
|
689 |
} |
|
690 |
} |
|
691 |
|
|
692 |
// Check if there was a database error |
|
693 |
if($database->is_error()) { |
|
694 |
set_error($database->get_error()); |
|
695 |
} |
|
696 |
|
|
697 |
// end of if install_tables |
|
698 |
} else { |
|
699 |
/** |
|
700 |
* DB - Exists |
|
701 |
* Tables also? |
|
702 |
* |
|
703 |
*/ |
|
704 |
$requested_tables = array("pages","sections","settings","users","groups","search","addons"); |
|
705 |
for($i=0;$i<count($requested_tables);$i++) $requested_tables[$i] = $table_prefix.$requested_tables[$i]; |
|
706 |
|
|
707 |
$result = mysql_list_tables( DB_NAME ); |
|
708 |
$all_tables = array(); |
|
709 |
for($i=0; $i < mysql_num_rows($result); $i++) $all_tables[] = mysql_table_name($result, $i); |
|
710 |
|
|
711 |
$missing_tables = array(); |
|
712 |
foreach($requested_tables as $temp_table) { |
|
713 |
if (!in_array($temp_table, $all_tables)) { |
|
714 |
$missing_tables[] = $temp_table; |
|
715 |
} |
|
716 |
} |
|
717 |
|
|
718 |
/** |
|
719 |
* If one or more needed tables are missing, so |
|
720 |
* we can't go on and have to display an error |
|
721 |
*/ |
|
722 |
if ( count($missing_tables) > 0 ) { |
|
723 |
$error_message = "One or more tables are missing in the selected database <b><font color='#990000'>".DB_NAME."</font></b>.<br />"; |
|
724 |
$error_message .= "Please install the missing tables or choose 'install tables' as recommend.<br />"; |
|
725 |
$error_message .= "Missing tables are: <b>".implode(", ", $missing_tables)."</b>"; |
|
726 |
|
|
727 |
set_error( $error_message ); |
|
728 |
} |
|
729 |
|
|
730 |
/** |
|
731 |
* Try to get some default settings ... |
|
732 |
*/ |
|
733 |
$vars = array( |
|
734 |
'DEFAULT_THEME' => "wb_theme", |
|
735 |
'THEME_URL' => WB_URL."/templates/wb_theme", |
|
736 |
'THEME_PATH' => WB_PATH."/templates/wb_theme", |
|
737 |
'LANGUAGE' => $_POST['default_language'], |
|
738 |
'SERVER_EMAIL' => "admin@yourdomain.com", |
|
739 |
'SMART_LOGIN' => false |
|
740 |
); |
|
741 |
foreach($vars as $k => $v) if (!defined($k)) define($k, $v); |
|
742 |
|
|
743 |
if (!isset($MESSAGE)) include (WB_PATH."/languages/".LANGUAGE.".php"); |
|
744 |
|
|
745 |
/** |
|
746 |
* The important part ... |
|
747 |
* Is there an valid user? |
|
748 |
*/ |
|
749 |
$result = $database->query("SELECT * from ".$table_prefix."users where username='".$_POST['admin_username']."'"); |
|
750 |
if ( $database->is_error() ) { |
|
751 |
set_error ($database->get_error() ); |
|
752 |
} |
|
753 |
if ($result->numRows() == 0) { |
|
754 |
/** |
|
755 |
* No matches found ... user properly unknown |
|
756 |
*/ |
|
757 |
set_error ("Unkown user. Please use a valid username."); |
|
758 |
} else { |
|
759 |
|
|
760 |
$data = $result->fetchRow(); |
|
761 |
/** |
|
762 |
* Does the password match |
|
763 |
*/ |
|
764 |
if ( md5($_POST['admin_password']) != $data['password']) { |
|
765 |
set_error ("Password didn't match"); |
|
766 |
} |
|
767 |
} |
|
768 |
} |
|
769 |
// Log the user in and go to Website Baker Administration |
|
770 |
$thisApp = new Login( |
|
771 |
array( |
|
772 |
"MAX_ATTEMPS" => "50", |
|
773 |
"WARNING_URL" => ADMIN_URL."/login/warning.html", |
|
774 |
"USERNAME_FIELDNAME" => 'admin_username', |
|
775 |
"PASSWORD_FIELDNAME" => 'admin_password', |
|
776 |
"REMEMBER_ME_OPTION" => SMART_LOGIN, |
|
777 |
"MIN_USERNAME_LEN" => "2", |
|
778 |
"MIN_PASSWORD_LEN" => "2", |
|
779 |
"MAX_USERNAME_LEN" => "30", |
|
780 |
"MAX_PASSWORD_LEN" => "30", |
|
781 |
'LOGIN_URL' => ADMIN_URL."/login/index.php", |
|
782 |
'DEFAULT_URL' => ADMIN_URL."/start/index.php", |
|
783 |
'TEMPLATE_DIR' => ADMIN_PATH."/login", |
|
784 |
'TEMPLATE_FILE' => "template.html", |
|
785 |
'FRONTEND' => false, |
|
786 |
'FORGOTTEN_DETAILS_APP' => ADMIN_URL."/login/forgot/index.php", |
|
787 |
'USERS_TABLE' => TABLE_PREFIX."users", |
|
788 |
'GROUPS_TABLE' => TABLE_PREFIX."groups", |
|
789 |
) |
|
790 |
); |
|
791 |
?> |
|
1 |
<?php |
|
2 |
/** |
|
3 |
* |
|
4 |
* @category backend |
|
5 |
* @package install |
|
6 |
* @author WebsiteBaker Project |
|
7 |
* @copyright 2004-2009, Ryan Djurovich |
|
8 |
* @copyright 2009-2011, Website Baker Org. e.V. |
|
9 |
* @link http://www.websitebaker2.org/ |
|
10 |
* @license http://www.gnu.org/licenses/gpl.html |
|
11 |
* @platform WebsiteBaker 2.8.x |
|
12 |
* @requirements PHP 5.2.2 and higher |
|
13 |
* @version $Id$ |
|
14 |
* @filesource $HeadURL: $ |
|
15 |
* @lastmodified $Date: $ |
|
16 |
* |
|
17 |
*/ |
|
18 |
|
|
19 |
$debug = true; |
|
20 |
|
|
21 |
if (true === $debug) { |
|
22 |
ini_set('display_errors', 1); |
|
23 |
error_reporting(E_ALL); |
|
24 |
} |
|
25 |
// Start a session |
|
26 |
if(!defined('SESSION_STARTED')) { |
|
27 |
session_name('wb_session_id'); |
|
28 |
session_start(); |
|
29 |
define('SESSION_STARTED', true); |
|
30 |
} |
|
31 |
// get random-part for session_name() |
|
32 |
list($usec,$sec) = explode(' ',microtime()); |
|
33 |
srand((float)$sec+((float)$usec*100000)); |
|
34 |
$session_rand = rand(1000,9999); |
|
35 |
|
|
36 |
// Function to set error |
|
37 |
function set_error($message, $field_name = '') { |
|
38 |
global $_POST; |
|
39 |
if(isset($message) AND $message != '') { |
|
40 |
// Copy values entered into session so user doesn't have to re-enter everything |
|
41 |
if(isset($_POST['website_title'])) { |
|
42 |
$_SESSION['wb_url'] = $_POST['wb_url']; |
|
43 |
$_SESSION['default_timezone'] = $_POST['default_timezone']; |
|
44 |
$_SESSION['default_language'] = $_POST['default_language']; |
|
45 |
if(!isset($_POST['operating_system'])) { |
|
46 |
$_SESSION['operating_system'] = 'linux'; |
|
47 |
} else { |
|
48 |
$_SESSION['operating_system'] = $_POST['operating_system']; |
|
49 |
} |
|
50 |
if(!isset($_POST['world_writeable'])) { |
|
51 |
$_SESSION['world_writeable'] = false; |
|
52 |
} else { |
|
53 |
$_SESSION['world_writeable'] = true; |
|
54 |
} |
|
55 |
$_SESSION['database_host'] = $_POST['database_host']; |
|
56 |
$_SESSION['database_username'] = $_POST['database_username']; |
|
57 |
$_SESSION['database_password'] = $_POST['database_password']; |
|
58 |
$_SESSION['database_name'] = $_POST['database_name']; |
|
59 |
$_SESSION['table_prefix'] = $_POST['table_prefix']; |
|
60 |
if(!isset($_POST['install_tables'])) { |
|
61 |
$_SESSION['install_tables'] = false; |
|
62 |
} else { |
|
63 |
$_SESSION['install_tables'] = true; |
|
64 |
} |
|
65 |
$_SESSION['website_title'] = $_POST['website_title']; |
|
66 |
$_SESSION['admin_username'] = $_POST['admin_username']; |
|
67 |
$_SESSION['admin_email'] = $_POST['admin_email']; |
|
68 |
$_SESSION['admin_password'] = $_POST['admin_password']; |
|
69 |
$_SESSION['admin_repassword'] = $_POST['admin_repassword']; |
|
70 |
} |
|
71 |
// Set the message |
|
72 |
$_SESSION['message'] = $message; |
|
73 |
// Set the element(s) to highlight |
|
74 |
if($field_name != '') { |
|
75 |
$_SESSION['ERROR_FIELD'] = $field_name; |
|
76 |
} |
|
77 |
// Specify that session support is enabled |
|
78 |
$_SESSION['session_support'] = '<font class="good">Enabled</font>'; |
|
79 |
// Redirect to first page again and exit |
|
80 |
header('Location: index.php?sessions_checked=true'); |
|
81 |
exit(); |
|
82 |
} |
|
83 |
} |
|
84 |
|
|
85 |
// Dummy class to allow modules' install scripts to call $admin->print_error |
|
86 |
class admin_dummy |
|
87 |
{ |
|
88 |
var $error=''; |
|
89 |
function print_error($message) |
|
90 |
{ |
|
91 |
$this->error=$message; |
|
92 |
} |
|
93 |
} |
|
94 |
|
|
95 |
// Function to workout what the default permissions are for files created by the webserver |
|
96 |
function default_file_mode($temp_dir) { |
|
97 |
$v = explode(".",PHP_VERSION); |
|
98 |
$v = $v[0].$v[1]; |
|
99 |
if($v > 41 AND is_writable($temp_dir)) { |
|
100 |
$filename = $temp_dir.'/test_permissions.txt'; |
|
101 |
$handle = fopen($filename, 'w'); |
|
102 |
fwrite($handle, 'This file is to get the default file permissions'); |
|
103 |
fclose($handle); |
|
104 |
$default_file_mode = '0'.substr(sprintf('%o', fileperms($filename)), -3); |
|
105 |
unlink($filename); |
|
106 |
} else { |
|
107 |
$default_file_mode = '0777'; |
|
108 |
} |
|
109 |
return $default_file_mode; |
|
110 |
} |
|
111 |
|
|
112 |
// Function to workout what the default permissions are for directories created by the webserver |
|
113 |
function default_dir_mode($temp_dir) { |
|
114 |
$v = explode(".",PHP_VERSION); |
|
115 |
$v = $v[0].$v[1]; |
|
116 |
if($v > 41 AND is_writable($temp_dir)) { |
|
117 |
$dirname = $temp_dir.'/test_permissions/'; |
|
118 |
mkdir($dirname); |
|
119 |
$default_dir_mode = '0'.substr(sprintf('%o', fileperms($dirname)), -3); |
|
120 |
rmdir($dirname); |
|
121 |
} else { |
|
122 |
$default_dir_mode = '0777'; |
|
123 |
} |
|
124 |
return $default_dir_mode; |
|
125 |
} |
|
126 |
|
|
127 |
function add_slashes($input) { |
|
128 |
if ( get_magic_quotes_gpc() || ( !is_string($input) ) ) { |
|
129 |
return $input; |
|
130 |
} |
|
131 |
$output = addslashes($input); |
|
132 |
return $output; |
|
133 |
} |
|
134 |
|
|
135 |
// Begin check to see if form was even submitted |
|
136 |
// Set error if no post vars found |
|
137 |
if(!isset($_POST['website_title'])) { |
|
138 |
set_error('Please fill-in the form below'); |
|
139 |
} |
|
140 |
// End check to see if form was even submitted |
|
141 |
|
|
142 |
// Begin path and timezone details code |
|
143 |
|
|
144 |
// Check if user has entered the installation url |
|
145 |
if(!isset($_POST['wb_url']) OR $_POST['wb_url'] == '') { |
|
146 |
set_error('Please enter an absolute URL', 'wb_url'); |
|
147 |
} else { |
|
148 |
$wb_url = $_POST['wb_url']; |
|
149 |
} |
|
150 |
// Remove any slashes at the end of the URL |
|
151 |
if(substr($wb_url, strlen($wb_url)-1, 1) == "/") { |
|
152 |
$wb_url = substr($wb_url, 0, strlen($wb_url)-1); |
|
153 |
} |
|
154 |
if(substr($wb_url, strlen($wb_url)-1, 1) == "\\") { |
|
155 |
$wb_url = substr($wb_url, 0, strlen($wb_url)-1); |
|
156 |
} |
|
157 |
if(substr($wb_url, strlen($wb_url)-1, 1) == "/") { |
|
158 |
$wb_url = substr($wb_url, 0, strlen($wb_url)-1); |
|
159 |
} |
|
160 |
if(substr($wb_url, strlen($wb_url)-1, 1) == "\\") { |
|
161 |
$wb_url = substr($wb_url, 0, strlen($wb_url)-1); |
|
162 |
} |
|
163 |
// Get the default time zone |
|
164 |
if(!isset($_POST['default_timezone']) OR !is_numeric($_POST['default_timezone'])) { |
|
165 |
set_error('Please select a valid default timezone', 'default_timezone'); |
|
166 |
} else { |
|
167 |
$default_timezone = $_POST['default_timezone']*60*60; |
|
168 |
} |
|
169 |
// End path and timezone details code |
|
170 |
|
|
171 |
// Get the default language |
|
172 |
$allowed_languages = array('BG','CA', 'CS', 'DA', 'DE', 'EN', 'ES', 'ET', 'FI', 'FR', 'HR', 'HU', 'IT', 'LV', 'NL', 'NO', 'PL', 'PT', 'RU','SE','SK','TR'); |
|
173 |
if(!isset($_POST['default_language']) OR !in_array($_POST['default_language'], $allowed_languages)) { |
|
174 |
set_error('Please select a valid default backend language','default_language'); |
|
175 |
} else { |
|
176 |
$default_language = $_POST['default_language']; |
|
177 |
// make sure the selected language file exists in the language folder |
|
178 |
if(!file_exists('../languages/' .$default_language .'.php')) { |
|
179 |
set_error('The language file: \'' .$default_language .'.php\' is missing. Upload file to language folder or choose another language','default_language'); |
|
180 |
} |
|
181 |
} |
|
182 |
// End default language details code |
|
183 |
|
|
184 |
// Begin operating system specific code |
|
185 |
// Get operating system |
|
186 |
if(!isset($_POST['operating_system']) OR $_POST['operating_system'] != 'linux' AND $_POST['operating_system'] != 'windows') { |
|
187 |
set_error('Please select a valid operating system'); |
|
188 |
} else { |
|
189 |
$operating_system = $_POST['operating_system']; |
|
190 |
} |
|
191 |
// Work-out file permissions |
|
192 |
if($operating_system == 'windows') { |
|
193 |
$file_mode = '0777'; |
|
194 |
$dir_mode = '0777'; |
|
195 |
} elseif(isset($_POST['world_writeable']) AND $_POST['world_writeable'] == 'true') { |
|
196 |
$file_mode = '0777'; |
|
197 |
$dir_mode = '0777'; |
|
198 |
} else { |
|
199 |
$file_mode = default_file_mode('../temp'); |
|
200 |
$dir_mode = default_dir_mode('../temp'); |
|
201 |
} |
|
202 |
// End operating system specific code |
|
203 |
|
|
204 |
// Begin database details code |
|
205 |
// Check if user has entered a database host |
|
206 |
if(!isset($_POST['database_host']) OR $_POST['database_host'] == '') { |
|
207 |
set_error('Please enter a database host name', 'database_host'); |
|
208 |
} else { |
|
209 |
$database_host = $_POST['database_host']; |
|
210 |
} |
|
211 |
// Check if user has entered a database username |
|
212 |
if(!isset($_POST['database_username']) OR $_POST['database_username'] == '') { |
|
213 |
set_error('Please enter a database username','database_username'); |
|
214 |
} else { |
|
215 |
$database_username = $_POST['database_username']; |
|
216 |
} |
|
217 |
// Check if user has entered a database password |
|
218 |
if(!isset($_POST['database_password'])) { |
|
219 |
set_error('Please enter a database password', 'database_password'); |
|
220 |
} else { |
|
221 |
$database_password = $_POST['database_password']; |
|
222 |
} |
|
223 |
// Check if user has entered a database name |
|
224 |
if(!isset($_POST['database_name']) OR $_POST['database_name'] == '') { |
|
225 |
set_error('Please enter a database name', 'database_name'); |
|
226 |
} else { |
|
227 |
// make sure only allowed characters are specified |
|
228 |
if(preg_match('/[^a-z0-9_-]+/i', $_POST['database_name'])) { |
|
229 |
// contains invalid characters (only a-z, A-Z, 0-9 and _ allowed to avoid problems with table/field names) |
|
230 |
set_error('Only characters a-z, A-Z, 0-9, - and _ allowed in database name.', 'database_name'); |
|
231 |
} |
|
232 |
$database_name = $_POST['database_name']; |
|
233 |
} |
|
234 |
// Get table prefix |
|
235 |
if(preg_match('/[^a-z0-9_]+/i', $_POST['table_prefix'])) { |
|
236 |
// contains invalid characters (only a-z, A-Z, 0-9 and _ allowed to avoid problems with table/field names) |
|
237 |
set_error('Only characters a-z, A-Z, 0-9 and _ allowed in table_prefix.', 'table_prefix'); |
|
238 |
} else { |
|
239 |
$table_prefix = $_POST['table_prefix']; |
|
240 |
} |
|
241 |
|
|
242 |
// Find out if the user wants to install tables and data |
|
243 |
if(isset($_POST['install_tables']) AND $_POST['install_tables'] == 'true') { |
|
244 |
$install_tables = true; |
|
245 |
} else { |
|
246 |
$install_tables = false; |
|
247 |
} |
|
248 |
// End database details code |
|
249 |
|
|
250 |
// Begin website title code |
|
251 |
// Get website title |
|
252 |
if(!isset($_POST['website_title']) OR $_POST['website_title'] == '') { |
|
253 |
set_error('Please enter a website title', 'website_title'); |
|
254 |
} else { |
|
255 |
$website_title = add_slashes($_POST['website_title']); |
|
256 |
} |
|
257 |
// End website title code |
|
258 |
|
|
259 |
// Begin admin user details code |
|
260 |
// Get admin username |
|
261 |
if(!isset($_POST['admin_username']) OR $_POST['admin_username'] == '') { |
|
262 |
set_error('Please enter a username for the Administrator account','admin_username'); |
|
263 |
} else { |
|
264 |
$admin_username = $_POST['admin_username']; |
|
265 |
} |
|
266 |
// Get admin email and validate it |
|
267 |
if(!isset($_POST['admin_email']) OR $_POST['admin_email'] == '') { |
|
268 |
set_error('Please enter an email for the Administrator account','admin_email'); |
|
269 |
} else { |
|
270 |
if(preg_match('/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/i', $_POST['admin_email'])) { |
|
271 |
$admin_email = $_POST['admin_email']; |
|
272 |
} else { |
|
273 |
set_error('Please enter a valid email address for the Administrator account','admin_email'); |
|
274 |
} |
|
275 |
} |
|
276 |
// Get the two admin passwords entered, and check that they match |
|
277 |
if(!isset($_POST['admin_password']) OR $_POST['admin_password'] == '') { |
|
278 |
set_error('Please enter a password for the Administrator account','admin_password'); |
|
279 |
} else { |
|
280 |
$admin_password = $_POST['admin_password']; |
|
281 |
} |
|
282 |
if(!isset($_POST['admin_repassword']) OR $_POST['admin_repassword'] == '') { |
|
283 |
set_error('Please make sure you re-enter the password for the Administrator account','admin_repassword'); |
|
284 |
} else { |
|
285 |
$admin_repassword = $_POST['admin_repassword']; |
|
286 |
} |
|
287 |
if($admin_password != $admin_repassword) { |
|
288 |
set_error('Sorry, the two Administrator account passwords you entered do not match','admin_repassword'); |
|
289 |
} |
|
290 |
// End admin user details code |
|
291 |
|
|
292 |
// Try and write settings to config file |
|
293 |
$config_content = "" . |
|
294 |
"<?php\n". |
|
295 |
"\n". |
|
296 |
"define('DB_TYPE', 'mysql');\n". |
|
297 |
"define('DB_HOST', '$database_host');\n". |
|
298 |
"define('DB_USERNAME', '$database_username');\n". |
|
299 |
"define('DB_PASSWORD', '$database_password');\n". |
|
300 |
"define('DB_NAME', '$database_name');\n". |
|
301 |
"define('TABLE_PREFIX', '$table_prefix');\n". |
|
302 |
"\n". |
|
303 |
"define('WB_PATH', dirname(__FILE__));\n". |
|
304 |
"define('WB_URL', '$wb_url');\n". |
|
305 |
"define('ADMIN_PATH', WB_PATH.'/admin');\n". |
|
306 |
"define('ADMIN_URL', '$wb_url/admin');\n". |
|
307 |
"\n". |
|
308 |
"require_once(WB_PATH.'/framework/initialize.php');\n". |
|
309 |
"\n". |
|
310 |
"?>"; |
|
311 |
|
|
312 |
$config_filename = '../config.php'; |
|
313 |
|
|
314 |
// Check if the file exists and is writable first. |
|
315 |
if(file_exists($config_filename) AND is_writable($config_filename)) { |
|
316 |
if(!$handle = fopen($config_filename, 'w')) { |
|
317 |
set_error("Cannot open the configuration file ($config_filename)"); |
|
318 |
} else { |
|
319 |
if (fwrite($handle, $config_content) === FALSE) { |
|
320 |
set_error("Cannot write to the configuration file ($config_filename)"); |
|
321 |
} |
|
322 |
// Close file |
|
323 |
fclose($handle); |
|
324 |
} |
|
325 |
} else { |
|
326 |
set_error("The configuration file $config_filename is not writable. Change its permissions so it is, then re-run step 4."); |
|
327 |
} |
|
328 |
|
|
329 |
// Define configuration vars |
|
330 |
define('DB_TYPE', 'mysql'); |
|
331 |
define('DB_HOST', $database_host); |
|
332 |
define('DB_USERNAME', $database_username); |
|
333 |
define('DB_PASSWORD', $database_password); |
|
334 |
define('DB_NAME', $database_name); |
|
335 |
define('TABLE_PREFIX', $table_prefix); |
|
336 |
define('WB_PATH', str_replace(array('/install','\install'), '',dirname(__FILE__))); |
|
337 |
define('WB_URL', $wb_url); |
|
338 |
define('ADMIN_PATH', WB_PATH.'/admin'); |
|
339 |
define('ADMIN_URL', $wb_url.'/admin'); |
|
340 |
|
|
341 |
// Check if the user has entered a correct path |
|
342 |
if(!file_exists(WB_PATH.'/framework/class.admin.php')) { |
|
343 |
set_error('It appears the Absolute path that you entered is incorrect'); |
|
344 |
} |
|
345 |
|
|
346 |
// Try connecting to database |
|
347 |
if(!@mysql_connect(DB_HOST, DB_USERNAME, DB_PASSWORD)) { |
|
348 |
set_error('Database host name, username and/or password incorrect. MySQL Error:<br />'.mysql_error()); |
|
349 |
} |
|
350 |
|
|
351 |
// Try to create the database |
|
352 |
mysql_query('CREATE DATABASE `'.$database_name.'`'); |
|
353 |
|
|
354 |
// Close the mysql connection |
|
355 |
mysql_close(); |
|
356 |
|
|
357 |
// Include WB functions file |
|
358 |
require_once(WB_PATH.'/framework/functions.php'); |
|
359 |
|
|
360 |
// Re-connect to the database, this time using in-build database class |
|
361 |
require_once(WB_PATH.'/framework/class.login.php'); |
|
362 |
$database=new database(); |
|
363 |
|
|
364 |
// Check if we should install tables |
|
365 |
if($install_tables == true) { |
|
366 |
if (!defined('WB_INSTALL_PROCESS')) define ('WB_INSTALL_PROCESS', true); |
|
367 |
// Remove tables if they exist |
|
368 |
|
|
369 |
// Pages table |
|
370 |
$pages = "DROP TABLE IF EXISTS `".TABLE_PREFIX."pages`"; |
|
371 |
$database->query($pages); |
|
372 |
// Sections table |
|
373 |
$sections = "DROP TABLE IF EXISTS `".TABLE_PREFIX."sections`"; |
|
374 |
$database->query($sections); |
|
375 |
// Settings table |
|
376 |
$settings = "DROP TABLE IF EXISTS `".TABLE_PREFIX."settings`"; |
|
377 |
$database->query($settings); |
|
378 |
// Users table |
|
379 |
$users = "DROP TABLE IF EXISTS `".TABLE_PREFIX."users`"; |
|
380 |
$database->query($users); |
|
381 |
// Groups table |
|
382 |
$groups = "DROP TABLE IF EXISTS `".TABLE_PREFIX."groups`"; |
|
383 |
$database->query($groups); |
|
384 |
// Search table |
|
385 |
$search = "DROP TABLE IF EXISTS `".TABLE_PREFIX."search`"; |
|
386 |
$database->query($search); |
|
387 |
// Addons table |
|
388 |
$addons = "DROP TABLE IF EXISTS `".TABLE_PREFIX."addons`"; |
|
389 |
$database->query($addons); |
|
390 |
|
|
391 |
// Try installing tables |
|
392 |
|
|
393 |
// Pages table |
|
394 |
$pages = 'CREATE TABLE `'.TABLE_PREFIX.'pages` ( `page_id` INT NOT NULL auto_increment,' |
|
395 |
. ' `parent` INT NOT NULL DEFAULT \'0\',' |
|
396 |
. ' `root_parent` INT NOT NULL DEFAULT \'0\',' |
|
397 |
. ' `level` INT NOT NULL DEFAULT \'0\',' |
|
398 |
. ' `link` TEXT NOT NULL,' |
|
399 |
. ' `target` VARCHAR( 7 ) NOT NULL DEFAULT \'\' ,' |
|
400 |
. ' `page_title` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
401 |
. ' `menu_title` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
402 |
. ' `description` TEXT NOT NULL ,' |
|
403 |
. ' `keywords` TEXT NOT NULL ,' |
|
404 |
. ' `page_trail` TEXT NOT NULL ,' |
|
405 |
. ' `template` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
406 |
. ' `visibility` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
407 |
. ' `position` INT NOT NULL DEFAULT \'0\',' |
|
408 |
. ' `menu` INT NOT NULL DEFAULT \'0\',' |
|
409 |
. ' `language` VARCHAR( 5 ) NOT NULL DEFAULT \'\' ,' |
|
410 |
. ' `searching` INT NOT NULL DEFAULT \'0\',' |
|
411 |
. ' `admin_groups` TEXT NOT NULL ,' |
|
412 |
. ' `admin_users` TEXT NOT NULL ,' |
|
413 |
. ' `viewing_groups` TEXT NOT NULL ,' |
|
414 |
. ' `viewing_users` TEXT NOT NULL ,' |
|
415 |
. ' `modified_when` INT NOT NULL DEFAULT \'0\',' |
|
416 |
. ' `modified_by` INT NOT NULL DEFAULT \'0\',' |
|
417 |
. ' PRIMARY KEY ( `page_id` ) ' |
|
418 |
. ' )'; |
|
419 |
$database->query($pages); |
|
420 |
|
|
421 |
// Sections table |
|
422 |
$pages = 'CREATE TABLE `'.TABLE_PREFIX.'sections` ( `section_id` INT NOT NULL auto_increment,' |
|
423 |
. ' `page_id` INT NOT NULL DEFAULT \'0\',' |
|
424 |
. ' `position` INT NOT NULL DEFAULT \'0\',' |
|
425 |
. ' `module` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
426 |
. ' `block` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
427 |
. ' `publ_start` VARCHAR( 255 ) NOT NULL DEFAULT \'0\' ,' |
|
428 |
. ' `publ_end` VARCHAR( 255 ) NOT NULL DEFAULT \'0\' ,' |
|
429 |
. ' PRIMARY KEY ( `section_id` ) ' |
|
430 |
. ' )'; |
|
431 |
$database->query($pages); |
|
432 |
|
|
433 |
require(ADMIN_PATH.'/interface/version.php'); |
|
434 |
|
|
435 |
// Settings table |
|
436 |
$settings='CREATE TABLE `'.TABLE_PREFIX.'settings` ( `setting_id` INT NOT NULL auto_increment,' |
|
437 |
. ' `name` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
438 |
. ' `value` TEXT NOT NULL ,' |
|
439 |
. ' PRIMARY KEY ( `setting_id` ) ' |
|
440 |
. ' )'; |
|
441 |
$database->query($settings); |
|
442 |
|
|
443 |
$settings_rows= "INSERT INTO `".TABLE_PREFIX."settings` " |
|
444 |
." (name, value) VALUES " |
|
445 |
." ('wb_version', '".VERSION."')," |
|
446 |
." ('website_title', '$website_title')," |
|
447 |
." ('website_description', '')," |
|
448 |
." ('website_keywords', '')," |
|
449 |
." ('website_header', '')," |
|
450 |
." ('website_footer', '')," |
|
451 |
." ('wysiwyg_style', 'font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px;')," |
|
452 |
." ('rename_files_on_upload', 'php,asp,phpx,aspx')," |
|
453 |
." ('er_level', '')," |
|
454 |
." ('default_language', '$default_language')," |
|
455 |
." ('app_name', 'wb_$session_rand')," |
|
456 |
." ('sec_anchor', 'wb_')," |
|
457 |
." ('default_timezone', '$default_timezone')," |
|
458 |
." ('default_date_format', 'M d Y')," |
|
459 |
." ('default_time_format', 'g:i A')," |
|
460 |
." ('redirect_timer', '1500')," |
|
461 |
." ('home_folders', 'true')," |
|
462 |
." ('default_template', 'round')," |
|
463 |
." ('default_theme', 'wb_theme')," |
|
464 |
." ('default_charset', 'utf-8')," |
|
465 |
." ('multiple_menus', 'true')," |
|
466 |
." ('page_level_limit', '4')," |
|
467 |
." ('intro_page', 'false')," |
|
468 |
." ('page_trash', 'inline')," |
|
469 |
." ('homepage_redirection', 'false')," |
|
470 |
." ('page_languages', 'true')," |
|
471 |
." ('wysiwyg_editor', 'fckeditor')," |
|
472 |
." ('manage_sections', 'true')," |
|
473 |
." ('section_blocks', 'true')," |
|
474 |
." ('smart_login', 'true')," |
|
475 |
." ('frontend_login', 'false')," |
|
476 |
." ('frontend_signup', 'false')," |
|
477 |
." ('search', 'public')," |
|
478 |
." ('page_extension', '.php')," |
|
479 |
." ('page_spacer', '-')," |
|
480 |
." ('pages_directory', '/pages')," |
|
481 |
." ('media_directory', '/media')," |
|
482 |
." ('operating_system', '$operating_system')," |
|
483 |
." ('string_file_mode', '$file_mode')," |
|
484 |
." ('string_dir_mode', '$dir_mode')," |
|
485 |
." ('wbmailer_routine', 'phpmail')," |
|
486 |
." ('server_email', 'admin@yourdomain.com')," // avoid that mail provider (e.g. mail.com) reject mails like yourname@mail.com |
|
487 |
." ('wbmailer_default_sendername', 'WB Mailer')," |
|
488 |
." ('wbmailer_smtp_host', '')," |
|
489 |
." ('wbmailer_smtp_auth', '')," |
|
490 |
." ('wbmailer_smtp_username', '')," |
|
491 |
." ('wbmailer_smtp_password', '')," |
|
492 |
." ('mediasettings', '')"; |
|
493 |
$database->query($settings_rows); |
|
494 |
|
|
495 |
// Users table |
|
496 |
$users = 'CREATE TABLE `'.TABLE_PREFIX.'users` ( `user_id` INT NOT NULL auto_increment,' |
|
497 |
. ' `group_id` INT NOT NULL DEFAULT \'0\',' |
|
498 |
. ' `groups_id` VARCHAR( 255 ) NOT NULL DEFAULT \'0\',' |
|
499 |
. ' `active` INT NOT NULL DEFAULT \'0\',' |
|
500 |
. ' `username` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
501 |
. ' `password` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
502 |
. ' `remember_key` VARCHAR( 255 ) NOT NULL DEFAULT \'\',' |
|
503 |
. ' `last_reset` INT NOT NULL DEFAULT \'0\',' |
|
504 |
. ' `display_name` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
505 |
. ' `email` TEXT NOT NULL ,' |
|
506 |
. ' `timezone` INT NOT NULL DEFAULT \'0\',' |
|
507 |
. ' `date_format` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
508 |
. ' `time_format` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
509 |
. ' `language` VARCHAR( 5 ) NOT NULL DEFAULT \'' .$default_language .'\' ,' |
|
510 |
. ' `home_folder` TEXT NOT NULL ,' |
|
511 |
. ' `login_when` INT NOT NULL DEFAULT \'0\',' |
|
512 |
. ' `login_ip` VARCHAR( 15 ) NOT NULL DEFAULT \'\' ,' |
|
513 |
. ' PRIMARY KEY ( `user_id` ) ' |
|
514 |
. ' )'; |
|
515 |
$database->query($users); |
|
516 |
|
|
517 |
// Groups table |
|
518 |
$groups = 'CREATE TABLE `'.TABLE_PREFIX.'groups` ( `group_id` INT NOT NULL auto_increment,' |
|
519 |
. ' `name` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
520 |
. ' `system_permissions` TEXT NOT NULL ,' |
|
521 |
. ' `module_permissions` TEXT NOT NULL ,' |
|
522 |
. ' `template_permissions` TEXT NOT NULL ,' |
|
523 |
. ' PRIMARY KEY ( `group_id` ) ' |
|
524 |
. ' )'; |
|
525 |
$database->query($groups); |
|
526 |
|
|
527 |
// Search settings table |
|
528 |
$search = 'CREATE TABLE `'.TABLE_PREFIX.'search` ( `search_id` INT NOT NULL auto_increment,' |
|
529 |
. ' `name` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
530 |
. ' `value` TEXT NOT NULL ,' |
|
531 |
. ' `extra` TEXT NOT NULL ,' |
|
532 |
. ' PRIMARY KEY ( `search_id` ) ' |
|
533 |
. ' )'; |
|
534 |
$database->query($search); |
|
535 |
|
|
536 |
// Addons table |
|
537 |
$addons = 'CREATE TABLE `'.TABLE_PREFIX.'addons` ( ' |
|
538 |
.'`addon_id` INT NOT NULL auto_increment ,' |
|
539 |
.'`type` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
540 |
.'`directory` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
541 |
.'`name` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
542 |
.'`description` TEXT NOT NULL ,' |
|
543 |
.'`function` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
544 |
.'`version` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
545 |
.'`platform` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
546 |
.'`author` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
547 |
.'`license` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,' |
|
548 |
.' PRIMARY KEY ( `addon_id` ) ' |
|
549 |
.' )'; |
|
550 |
$database->query($addons); |
|
551 |
|
|
552 |
// Insert default data |
|
553 |
|
|
554 |
// Admin group |
|
555 |
$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'; |
|
556 |
$insert_admin_group = "INSERT INTO `".TABLE_PREFIX."groups` VALUES ('1', 'Administrators', '$full_system_permissions', '', '')"; |
|
557 |
$database->query($insert_admin_group); |
|
558 |
// Admin user |
|
559 |
$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')"; |
|
560 |
$database->query($insert_admin_user); |
|
561 |
|
|
562 |
// Search header |
|
563 |
$search_header = addslashes(' |
|
564 |
<h1>[TEXT_SEARCH]</h1> |
|
565 |
|
|
566 |
<form name="searchpage" action="[WB_URL]/search/index.php" method="get"> |
|
567 |
<table cellpadding="3" cellspacing="0" border="0" width="500"> |
|
568 |
<tr> |
|
569 |
<td> |
|
570 |
<input type="hidden" name="search_path" value="[SEARCH_PATH]" /> |
|
571 |
<input type="text" name="string" value="[SEARCH_STRING]" style="width: 100%;" /> |
|
572 |
</td> |
|
573 |
<td width="150"> |
|
574 |
<input type="submit" value="[TEXT_SEARCH]" style="width: 100%;" /> |
|
575 |
</td> |
|
576 |
</tr> |
|
577 |
<tr> |
|
578 |
<td colspan="2"> |
|
579 |
<input type="radio" name="match" id="match_all" value="all"[ALL_CHECKED] /> |
|
580 |
<label for="match_all">[TEXT_ALL_WORDS]</label> |
|
581 |
<input type="radio" name="match" id="match_any" value="any"[ANY_CHECKED] /> |
|
582 |
<label for="match_any">[TEXT_ANY_WORDS]</label> |
|
583 |
<input type="radio" name="match" id="match_exact" value="exact"[EXACT_CHECKED] /> |
|
584 |
<label for="match_exact">[TEXT_EXACT_MATCH]</label> |
|
585 |
</td> |
|
586 |
</tr> |
|
587 |
</table> |
|
588 |
|
|
589 |
</form> |
|
590 |
|
|
591 |
<hr /> |
|
592 |
'); |
|
593 |
$insert_search_header = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'header', '$search_header', '')"; |
|
594 |
$database->query($insert_search_header); |
|
595 |
// Search footer |
|
596 |
$search_footer = addslashes(''); |
|
597 |
$insert_search_footer = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'footer', '$search_footer', '')"; |
|
598 |
$database->query($insert_search_footer); |
|
599 |
// Search results header |
|
600 |
$search_results_header = addslashes(''. |
|
601 |
'[TEXT_RESULTS_FOR] \'<b>[SEARCH_STRING]</b>\': |
|
602 |
<table cellpadding="2" cellspacing="0" border="0" width="100%" style="padding-top: 10px;">'); |
|
603 |
$insert_search_results_header = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'results_header', '$search_results_header', '')"; |
|
604 |
$database->query($insert_search_results_header); |
|
605 |
// Search results loop |
|
606 |
$search_results_loop = addslashes(''. |
|
607 |
'<tr style="background-color: #F0F0F0;"> |
|
608 |
<td><a href="[LINK]">[TITLE]</a></td> |
|
609 |
<td align="right">[TEXT_LAST_UPDATED_BY] [DISPLAY_NAME] ([USERNAME]) [TEXT_ON] [DATE]</td> |
|
610 |
</tr> |
|
611 |
<tr><td colspan="2" style="text-align: justify; padding-bottom: 5px;">[DESCRIPTION]</td></tr> |
|
612 |
<tr><td colspan="2" style="text-align: justify; padding-bottom: 10px;">[EXCERPT]</td></tr>'); |
|
613 |
|
|
614 |
$insert_search_results_loop = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'results_loop', '$search_results_loop', '')"; |
|
615 |
$database->query($insert_search_results_loop); |
|
616 |
// Search results footer |
|
617 |
$search_results_footer = addslashes("</table>"); |
|
618 |
$insert_search_results_footer = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'results_footer', '$search_results_footer', '')"; |
|
619 |
$database->query($insert_search_results_footer); |
|
620 |
// Search no results |
|
621 |
$search_no_results = addslashes('<tr><td><p>[TEXT_NO_RESULTS]</p></td></tr>'); |
|
622 |
$insert_search_no_results = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'no_results', '$search_no_results', '')"; |
|
623 |
$database->query($insert_search_no_results); |
|
624 |
// Search module-order |
|
625 |
$search_module_order = addslashes('faqbaker,manual,wysiwyg'); |
|
626 |
$insert_search_module_order = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'module_order', '$search_module_order', '')"; |
|
627 |
$database->query($insert_search_module_order); |
|
628 |
// Search max lines of excerpt |
|
629 |
$search_max_excerpt = addslashes('15'); |
|
630 |
$insert_search_max_excerpt = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'max_excerpt', '$search_max_excerpt', '')"; |
|
631 |
$database->query($insert_search_max_excerpt); |
|
632 |
// max time to search per module |
|
633 |
$search_time_limit = addslashes('0'); |
|
634 |
$insert_search_time_limit = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'time_limit', '$search_time_limit', '')"; |
|
635 |
$database->query($insert_search_time_limit); |
|
636 |
// some config-elements |
|
637 |
$database->query("INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'cfg_enable_old_search', 'true', '')"); |
|
638 |
$database->query("INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'cfg_search_keywords', 'true', '')"); |
|
639 |
$database->query("INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'cfg_search_description', 'true', '')"); |
|
640 |
$database->query("INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'cfg_show_description', 'true', '')"); |
|
641 |
$database->query("INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'cfg_enable_flush', 'false', '')"); |
|
642 |
// Search template |
|
643 |
$database->query("INSERT INTO `".TABLE_PREFIX."search` (name) VALUES ('template')"); |
|
644 |
|
|
645 |
require_once(WB_PATH.'/framework/initialize.php'); |
|
646 |
|
|
647 |
// Include the PclZip class file (thanks to |
|
648 |
require_once(WB_PATH.'/include/pclzip/pclzip.lib.php'); |
|
649 |
|
|
650 |
// Install add-ons |
|
651 |
if(file_exists(WB_PATH.'/install/modules')) { |
|
652 |
// Unpack pre-packaged modules |
|
653 |
|
|
654 |
} |
|
655 |
if(file_exists(WB_PATH.'/install/templates')) { |
|
656 |
// Unpack pre-packaged templates |
|
657 |
|
|
658 |
} |
|
659 |
if(file_exists(WB_PATH.'/install/languages')) { |
|
660 |
// Unpack pre-packaged languages |
|
661 |
|
|
662 |
} |
|
663 |
|
|
664 |
$admin=new admin_dummy(); |
|
665 |
// Load addons into DB |
|
666 |
$dirs['modules'] = WB_PATH.'/modules/'; |
|
667 |
$dirs['templates'] = WB_PATH.'/templates/'; |
|
668 |
$dirs['languages'] = WB_PATH.'/languages/'; |
|
669 |
foreach($dirs AS $type => $dir) { |
|
670 |
if($handle = opendir($dir)) { |
|
671 |
while(false !== ($file = readdir($handle))) { |
|
672 |
if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'admin.php' AND $file != 'index.php') { |
|
673 |
// Get addon type |
|
674 |
if($type == 'modules') { |
|
675 |
load_module($dir.'/'.$file, true); |
|
676 |
// Pretty ugly hack to let modules run $admin->set_error |
|
677 |
// See dummy class definition admin_dummy above |
|
678 |
if ($admin->error!='') { |
|
679 |
set_error($admin->error); |
|
680 |
} |
|
681 |
} elseif($type == 'templates') { |
|
682 |
load_template($dir.'/'.$file); |
|
683 |
} elseif($type == 'languages') { |
|
684 |
load_language($dir.'/'.$file); |
|
685 |
} |
|
686 |
} |
|
687 |
} |
|
688 |
closedir($handle); |
|
689 |
} |
|
690 |
} |
|
691 |
|
|
692 |
// Check if there was a database error |
|
693 |
if($database->is_error()) { |
|
694 |
set_error($database->get_error()); |
|
695 |
} |
|
696 |
|
|
697 |
// end of if install_tables |
|
698 |
} else { |
|
699 |
/** |
|
700 |
* DB - Exists |
|
701 |
* Tables also? |
|
702 |
* |
|
703 |
*/ |
|
704 |
$requested_tables = array("pages","sections","settings","users","groups","search","addons"); |
|
705 |
for($i=0;$i<count($requested_tables);$i++) $requested_tables[$i] = $table_prefix.$requested_tables[$i]; |
Also available in: Unified diff
update install, changed some default settings to enabled