1 |
1470
|
Luisehahne
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
*
|
4 |
|
|
* @category backend
|
5 |
|
|
* @package install
|
6 |
1695
|
Luisehahne
|
* @author Ryan Djurovich, WebsiteBaker Project
|
7 |
|
|
* @copyright 2009-2012, WebsiteBaker Org. e.V.
|
8 |
1470
|
Luisehahne
|
* @link http://www.websitebaker2.org/
|
9 |
|
|
* @license http://www.gnu.org/licenses/gpl.html
|
10 |
|
|
* @platform WebsiteBaker 2.8.x
|
11 |
|
|
* @requirements PHP 5.2.2 and higher
|
12 |
|
|
* @version $Id$
|
13 |
|
|
* @filesource $HeadURL: $
|
14 |
|
|
* @lastmodified $Date: $
|
15 |
|
|
*
|
16 |
|
|
*/
|
17 |
|
|
|
18 |
|
|
$debug = true;
|
19 |
|
|
|
20 |
|
|
if (true === $debug) {
|
21 |
|
|
ini_set('display_errors', 1);
|
22 |
|
|
error_reporting(E_ALL);
|
23 |
|
|
}
|
24 |
|
|
// Start a session
|
25 |
|
|
if(!defined('SESSION_STARTED')) {
|
26 |
|
|
session_name('wb_session_id');
|
27 |
|
|
session_start();
|
28 |
|
|
define('SESSION_STARTED', true);
|
29 |
|
|
}
|
30 |
|
|
// get random-part for session_name()
|
31 |
|
|
list($usec,$sec) = explode(' ',microtime());
|
32 |
|
|
srand((float)$sec+((float)$usec*100000));
|
33 |
|
|
$session_rand = rand(1000,9999);
|
34 |
1686
|
darkviper
|
if(!class_exists('WbAutoloader', false)) {
|
35 |
|
|
include(dirname(dirname(__FILE__)).'/framework/WbAutoloader.php');
|
36 |
|
|
}
|
37 |
|
|
WbAutoloader::doRegister(array('admin'=>'a', 'modules'=>'m'));
|
38 |
1470
|
Luisehahne
|
|
39 |
|
|
// Function to set error
|
40 |
|
|
function set_error($message, $field_name = '') {
|
41 |
|
|
global $_POST;
|
42 |
|
|
if(isset($message) AND $message != '') {
|
43 |
|
|
// Copy values entered into session so user doesn't have to re-enter everything
|
44 |
|
|
if(isset($_POST['website_title'])) {
|
45 |
1737
|
Luisehahne
|
$_SESSION['website_title'] = $_POST['website_title'];
|
46 |
1470
|
Luisehahne
|
$_SESSION['default_timezone'] = $_POST['default_timezone'];
|
47 |
|
|
$_SESSION['default_language'] = $_POST['default_language'];
|
48 |
|
|
if(!isset($_POST['operating_system'])) {
|
49 |
|
|
$_SESSION['operating_system'] = 'linux';
|
50 |
|
|
} else {
|
51 |
|
|
$_SESSION['operating_system'] = $_POST['operating_system'];
|
52 |
|
|
}
|
53 |
|
|
if(!isset($_POST['world_writeable'])) {
|
54 |
|
|
$_SESSION['world_writeable'] = false;
|
55 |
|
|
} else {
|
56 |
|
|
$_SESSION['world_writeable'] = true;
|
57 |
|
|
}
|
58 |
|
|
$_SESSION['database_host'] = $_POST['database_host'];
|
59 |
|
|
$_SESSION['database_username'] = $_POST['database_username'];
|
60 |
1737
|
Luisehahne
|
$_SESSION['database_password'] = '';
|
61 |
1470
|
Luisehahne
|
$_SESSION['database_name'] = $_POST['database_name'];
|
62 |
|
|
$_SESSION['table_prefix'] = $_POST['table_prefix'];
|
63 |
|
|
if(!isset($_POST['install_tables'])) {
|
64 |
1737
|
Luisehahne
|
$_SESSION['install_tables'] = true;
|
65 |
1470
|
Luisehahne
|
} else {
|
66 |
|
|
$_SESSION['install_tables'] = true;
|
67 |
|
|
}
|
68 |
|
|
$_SESSION['website_title'] = $_POST['website_title'];
|
69 |
|
|
$_SESSION['admin_username'] = $_POST['admin_username'];
|
70 |
|
|
$_SESSION['admin_email'] = $_POST['admin_email'];
|
71 |
1737
|
Luisehahne
|
$_SESSION['admin_password'] = '';
|
72 |
|
|
$_SESSION['admin_repassword'] = '';
|
73 |
1470
|
Luisehahne
|
}
|
74 |
|
|
// Set the message
|
75 |
|
|
$_SESSION['message'] = $message;
|
76 |
|
|
// Set the element(s) to highlight
|
77 |
|
|
if($field_name != '') {
|
78 |
|
|
$_SESSION['ERROR_FIELD'] = $field_name;
|
79 |
|
|
}
|
80 |
|
|
// Specify that session support is enabled
|
81 |
|
|
$_SESSION['session_support'] = '<font class="good">Enabled</font>';
|
82 |
|
|
// Redirect to first page again and exit
|
83 |
|
|
header('Location: index.php?sessions_checked=true');
|
84 |
|
|
exit();
|
85 |
|
|
}
|
86 |
|
|
}
|
87 |
1529
|
Luisehahne
|
/* */
|
88 |
1470
|
Luisehahne
|
|
89 |
|
|
// Function to workout what the default permissions are for files created by the webserver
|
90 |
|
|
function default_file_mode($temp_dir) {
|
91 |
|
|
$v = explode(".",PHP_VERSION);
|
92 |
|
|
$v = $v[0].$v[1];
|
93 |
|
|
if($v > 41 AND is_writable($temp_dir)) {
|
94 |
|
|
$filename = $temp_dir.'/test_permissions.txt';
|
95 |
|
|
$handle = fopen($filename, 'w');
|
96 |
|
|
fwrite($handle, 'This file is to get the default file permissions');
|
97 |
|
|
fclose($handle);
|
98 |
|
|
$default_file_mode = '0'.substr(sprintf('%o', fileperms($filename)), -3);
|
99 |
|
|
unlink($filename);
|
100 |
|
|
} else {
|
101 |
|
|
$default_file_mode = '0777';
|
102 |
|
|
}
|
103 |
|
|
return $default_file_mode;
|
104 |
|
|
}
|
105 |
|
|
|
106 |
|
|
// Function to workout what the default permissions are for directories created by the webserver
|
107 |
|
|
function default_dir_mode($temp_dir) {
|
108 |
|
|
$v = explode(".",PHP_VERSION);
|
109 |
|
|
$v = $v[0].$v[1];
|
110 |
|
|
if($v > 41 AND is_writable($temp_dir)) {
|
111 |
|
|
$dirname = $temp_dir.'/test_permissions/';
|
112 |
|
|
mkdir($dirname);
|
113 |
|
|
$default_dir_mode = '0'.substr(sprintf('%o', fileperms($dirname)), -3);
|
114 |
|
|
rmdir($dirname);
|
115 |
|
|
} else {
|
116 |
|
|
$default_dir_mode = '0777';
|
117 |
|
|
}
|
118 |
|
|
return $default_dir_mode;
|
119 |
|
|
}
|
120 |
|
|
|
121 |
|
|
function add_slashes($input) {
|
122 |
|
|
if ( get_magic_quotes_gpc() || ( !is_string($input) ) ) {
|
123 |
|
|
return $input;
|
124 |
|
|
}
|
125 |
|
|
$output = addslashes($input);
|
126 |
|
|
return $output;
|
127 |
|
|
}
|
128 |
|
|
|
129 |
|
|
// Begin check to see if form was even submitted
|
130 |
|
|
// Set error if no post vars found
|
131 |
|
|
if(!isset($_POST['website_title'])) {
|
132 |
1725
|
Luisehahne
|
set_error('Please fill-in the wesite title below');
|
133 |
1470
|
Luisehahne
|
}
|
134 |
|
|
// End check to see if form was even submitted
|
135 |
|
|
|
136 |
|
|
// Begin path and timezone details code
|
137 |
|
|
|
138 |
|
|
// Check if user has entered the installation url
|
139 |
|
|
if(!isset($_POST['wb_url']) OR $_POST['wb_url'] == '') {
|
140 |
|
|
set_error('Please enter an absolute URL', 'wb_url');
|
141 |
|
|
} else {
|
142 |
|
|
$wb_url = $_POST['wb_url'];
|
143 |
|
|
}
|
144 |
|
|
// Remove any slashes at the end of the URL
|
145 |
|
|
if(substr($wb_url, strlen($wb_url)-1, 1) == "/") {
|
146 |
|
|
$wb_url = substr($wb_url, 0, strlen($wb_url)-1);
|
147 |
|
|
}
|
148 |
|
|
if(substr($wb_url, strlen($wb_url)-1, 1) == "\\") {
|
149 |
|
|
$wb_url = substr($wb_url, 0, strlen($wb_url)-1);
|
150 |
|
|
}
|
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 |
|
|
// Get the default time zone
|
158 |
|
|
if(!isset($_POST['default_timezone']) OR !is_numeric($_POST['default_timezone'])) {
|
159 |
|
|
set_error('Please select a valid default timezone', 'default_timezone');
|
160 |
|
|
} else {
|
161 |
|
|
$default_timezone = $_POST['default_timezone']*60*60;
|
162 |
|
|
}
|
163 |
|
|
// End path and timezone details code
|
164 |
|
|
|
165 |
|
|
// Get the default language
|
166 |
|
|
$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');
|
167 |
|
|
if(!isset($_POST['default_language']) OR !in_array($_POST['default_language'], $allowed_languages)) {
|
168 |
|
|
set_error('Please select a valid default backend language','default_language');
|
169 |
|
|
} else {
|
170 |
|
|
$default_language = $_POST['default_language'];
|
171 |
|
|
// make sure the selected language file exists in the language folder
|
172 |
|
|
if(!file_exists('../languages/' .$default_language .'.php')) {
|
173 |
|
|
set_error('The language file: \'' .$default_language .'.php\' is missing. Upload file to language folder or choose another language','default_language');
|
174 |
|
|
}
|
175 |
|
|
}
|
176 |
|
|
// End default language details code
|
177 |
|
|
|
178 |
|
|
// Begin operating system specific code
|
179 |
|
|
// Get operating system
|
180 |
|
|
if(!isset($_POST['operating_system']) OR $_POST['operating_system'] != 'linux' AND $_POST['operating_system'] != 'windows') {
|
181 |
|
|
set_error('Please select a valid operating system');
|
182 |
|
|
} else {
|
183 |
|
|
$operating_system = $_POST['operating_system'];
|
184 |
|
|
}
|
185 |
|
|
// Work-out file permissions
|
186 |
|
|
if($operating_system == 'windows') {
|
187 |
|
|
$file_mode = '0777';
|
188 |
|
|
$dir_mode = '0777';
|
189 |
|
|
} elseif(isset($_POST['world_writeable']) AND $_POST['world_writeable'] == 'true') {
|
190 |
|
|
$file_mode = '0777';
|
191 |
|
|
$dir_mode = '0777';
|
192 |
|
|
} else {
|
193 |
|
|
$file_mode = default_file_mode('../temp');
|
194 |
|
|
$dir_mode = default_dir_mode('../temp');
|
195 |
|
|
}
|
196 |
|
|
// End operating system specific code
|
197 |
|
|
|
198 |
|
|
// Begin database details code
|
199 |
|
|
// Check if user has entered a database host
|
200 |
|
|
if(!isset($_POST['database_host']) OR $_POST['database_host'] == '') {
|
201 |
|
|
set_error('Please enter a database host name', 'database_host');
|
202 |
|
|
} else {
|
203 |
|
|
$database_host = $_POST['database_host'];
|
204 |
1770
|
Luisehahne
|
}
|
205 |
1470
|
Luisehahne
|
// Check if user has entered a database name
|
206 |
|
|
if(!isset($_POST['database_name']) OR $_POST['database_name'] == '') {
|
207 |
|
|
set_error('Please enter a database name', 'database_name');
|
208 |
|
|
} else {
|
209 |
|
|
// make sure only allowed characters are specified
|
210 |
1770
|
Luisehahne
|
if(!preg_match('/^[a-z0-9_-]*$/i', $_POST['database_name'])) {
|
211 |
1470
|
Luisehahne
|
// contains invalid characters (only a-z, A-Z, 0-9 and _ allowed to avoid problems with table/field names)
|
212 |
|
|
set_error('Only characters a-z, A-Z, 0-9, - and _ allowed in database name.', 'database_name');
|
213 |
|
|
}
|
214 |
|
|
$database_name = $_POST['database_name'];
|
215 |
|
|
}
|
216 |
|
|
// Get table prefix
|
217 |
1770
|
Luisehahne
|
if(!preg_match('/^[a-z0-9_]*$/i', $_POST['table_prefix'])) {
|
218 |
1470
|
Luisehahne
|
// contains invalid characters (only a-z, A-Z, 0-9 and _ allowed to avoid problems with table/field names)
|
219 |
|
|
set_error('Only characters a-z, A-Z, 0-9 and _ allowed in table_prefix.', 'table_prefix');
|
220 |
|
|
} else {
|
221 |
|
|
$table_prefix = $_POST['table_prefix'];
|
222 |
|
|
}
|
223 |
|
|
|
224 |
1770
|
Luisehahne
|
// Check if user has entered a database username
|
225 |
|
|
if(!isset($_POST['database_username']) OR $_POST['database_username'] == '') {
|
226 |
|
|
set_error('Please enter a database username','database_username');
|
227 |
|
|
} else {
|
228 |
|
|
$database_username = $_POST['database_username'];
|
229 |
|
|
}
|
230 |
|
|
// Check if user has entered a database password
|
231 |
|
|
if(!isset($_POST['database_password'])) {
|
232 |
|
|
set_error('Please enter a database password', 'database_password');
|
233 |
|
|
} else {
|
234 |
|
|
$database_password = $_POST['database_password'];
|
235 |
|
|
}
|
236 |
|
|
|
237 |
1470
|
Luisehahne
|
// Find out if the user wants to install tables and data
|
238 |
1695
|
Luisehahne
|
$install_tables = ((isset($_POST['install_tables']) AND $_POST['install_tables'] == 'true'));
|
239 |
1470
|
Luisehahne
|
// End database details code
|
240 |
|
|
|
241 |
|
|
// Begin website title code
|
242 |
|
|
// Get website title
|
243 |
|
|
if(!isset($_POST['website_title']) OR $_POST['website_title'] == '') {
|
244 |
|
|
set_error('Please enter a website title', 'website_title');
|
245 |
|
|
} else {
|
246 |
|
|
$website_title = add_slashes($_POST['website_title']);
|
247 |
|
|
}
|
248 |
|
|
// End website title code
|
249 |
|
|
|
250 |
|
|
// Begin admin user details code
|
251 |
|
|
// Get admin username
|
252 |
|
|
if(!isset($_POST['admin_username']) OR $_POST['admin_username'] == '') {
|
253 |
|
|
set_error('Please enter a username for the Administrator account','admin_username');
|
254 |
|
|
} else {
|
255 |
|
|
$admin_username = $_POST['admin_username'];
|
256 |
|
|
}
|
257 |
|
|
// Get admin email and validate it
|
258 |
|
|
if(!isset($_POST['admin_email']) OR $_POST['admin_email'] == '') {
|
259 |
|
|
set_error('Please enter an email for the Administrator account','admin_email');
|
260 |
|
|
} else {
|
261 |
|
|
if(preg_match('/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/i', $_POST['admin_email'])) {
|
262 |
|
|
$admin_email = $_POST['admin_email'];
|
263 |
|
|
} else {
|
264 |
|
|
set_error('Please enter a valid email address for the Administrator account','admin_email');
|
265 |
|
|
}
|
266 |
|
|
}
|
267 |
|
|
// Get the two admin passwords entered, and check that they match
|
268 |
|
|
if(!isset($_POST['admin_password']) OR $_POST['admin_password'] == '') {
|
269 |
|
|
set_error('Please enter a password for the Administrator account','admin_password');
|
270 |
|
|
} else {
|
271 |
|
|
$admin_password = $_POST['admin_password'];
|
272 |
|
|
}
|
273 |
|
|
if(!isset($_POST['admin_repassword']) OR $_POST['admin_repassword'] == '') {
|
274 |
|
|
set_error('Please make sure you re-enter the password for the Administrator account','admin_repassword');
|
275 |
|
|
} else {
|
276 |
|
|
$admin_repassword = $_POST['admin_repassword'];
|
277 |
|
|
}
|
278 |
|
|
if($admin_password != $admin_repassword) {
|
279 |
|
|
set_error('Sorry, the two Administrator account passwords you entered do not match','admin_repassword');
|
280 |
|
|
}
|
281 |
|
|
// End admin user details code
|
282 |
|
|
|
283 |
|
|
// Try and write settings to config file
|
284 |
|
|
$config_content = "" .
|
285 |
|
|
"<?php\n".
|
286 |
|
|
"\n".
|
287 |
1639
|
Luisehahne
|
"define('DEBUG', false);\n".
|
288 |
1470
|
Luisehahne
|
"define('DB_TYPE', 'mysql');\n".
|
289 |
|
|
"define('DB_HOST', '$database_host');\n".
|
290 |
1529
|
Luisehahne
|
"define('DB_NAME', '$database_name');\n".
|
291 |
1470
|
Luisehahne
|
"define('DB_USERNAME', '$database_username');\n".
|
292 |
|
|
"define('DB_PASSWORD', '$database_password');\n".
|
293 |
|
|
"define('TABLE_PREFIX', '$table_prefix');\n".
|
294 |
|
|
"\n".
|
295 |
|
|
"define('WB_URL', '$wb_url');\n".
|
296 |
1638
|
darkviper
|
"define('ADMIN_DIRECTORY', 'admin'); // no leading/trailing slash or backslash!! A simple directory only!!\n".
|
297 |
1470
|
Luisehahne
|
"\n".
|
298 |
1821
|
Luisehahne
|
"require_once(dirname(__FILE__).'/framework/initialize.php');\n";
|
299 |
1470
|
Luisehahne
|
|
300 |
|
|
$config_filename = '../config.php';
|
301 |
|
|
// Check if the file exists and is writable first.
|
302 |
|
|
if(file_exists($config_filename) AND is_writable($config_filename)) {
|
303 |
|
|
if(!$handle = fopen($config_filename, 'w')) {
|
304 |
|
|
set_error("Cannot open the configuration file ($config_filename)");
|
305 |
|
|
} else {
|
306 |
|
|
if (fwrite($handle, $config_content) === FALSE) {
|
307 |
|
|
set_error("Cannot write to the configuration file ($config_filename)");
|
308 |
|
|
}
|
309 |
|
|
// Close file
|
310 |
|
|
fclose($handle);
|
311 |
|
|
}
|
312 |
|
|
} else {
|
313 |
|
|
set_error("The configuration file $config_filename is not writable. Change its permissions so it is, then re-run step 4.");
|
314 |
|
|
}
|
315 |
|
|
|
316 |
|
|
// Define configuration vars
|
317 |
1639
|
Luisehahne
|
define('DEBUG', false);
|
318 |
1470
|
Luisehahne
|
define('DB_TYPE', 'mysql');
|
319 |
|
|
define('DB_HOST', $database_host);
|
320 |
1529
|
Luisehahne
|
define('DB_NAME', $database_name);
|
321 |
1470
|
Luisehahne
|
define('DB_USERNAME', $database_username);
|
322 |
|
|
define('DB_PASSWORD', $database_password);
|
323 |
|
|
define('TABLE_PREFIX', $table_prefix);
|
324 |
1686
|
darkviper
|
define('WB_PATH', dirname(dirname(__FILE__)));
|
325 |
1470
|
Luisehahne
|
define('WB_URL', $wb_url);
|
326 |
1686
|
darkviper
|
define('ADMIN_DIRECTORY', 'admin');
|
327 |
|
|
define('ADMIN_PATH', WB_PATH.'/'.ADMIN_DIRECTORY);
|
328 |
|
|
define('ADMIN_URL', $wb_url.'/'.ADMIN_DIRECTORY);
|
329 |
1470
|
Luisehahne
|
|
330 |
|
|
// Check if the user has entered a correct path
|
331 |
1821
|
Luisehahne
|
if(!file_exists(WB_PATH.'/framework/class.admin.php')) {
|
332 |
|
|
set_error('It appears the Absolute path that you entered is incorrect');
|
333 |
|
|
}
|
334 |
1686
|
darkviper
|
$sSqlUrl = DB_TYPE.'://'.DB_USERNAME.':'.DB_PASSWORD.'@'.DB_HOST.'/'.DB_NAME;
|
335 |
|
|
$database = WbDatabase::getInstance();
|
336 |
|
|
$database->doConnect($sSqlUrl);
|
337 |
1470
|
Luisehahne
|
|
338 |
1686
|
darkviper
|
$sSecMod = (defined('SECURE_FORM_MODULE') && SECURE_FORM_MODULE != '') ? '.'.SECURE_FORM_MODULE : '';
|
339 |
|
|
$sSecMod = WB_PATH.'/framework/SecureForm'.$sSecMod.'.php';
|
340 |
|
|
require_once($sSecMod);
|
341 |
|
|
require_once(WB_PATH.'/framework/class.admin.php');
|
342 |
1470
|
Luisehahne
|
|
343 |
1529
|
Luisehahne
|
// Dummy class to allow modules' install scripts to call $admin->print_error
|
344 |
1686
|
darkviper
|
class admin_dummy extends admin
|
345 |
1529
|
Luisehahne
|
{
|
346 |
1686
|
darkviper
|
var $error='';
|
347 |
|
|
function print_error($message, $link = 'index.php', $auto_footer = true)
|
348 |
|
|
{
|
349 |
|
|
$this->error=$message;
|
350 |
|
|
}
|
351 |
1529
|
Luisehahne
|
}
|
352 |
1470
|
Luisehahne
|
|
353 |
1822
|
Luisehahne
|
// core tables only structure
|
354 |
1821
|
Luisehahne
|
$sSqlFileName = dirname(__FILE__).'/sql/websitebaker.sql';
|
355 |
|
|
if(!$database->SqlImport($sSqlFileName,TABLE_PREFIX, false)) { set_error($database->get_error()); }
|
356 |
1684
|
Luisehahne
|
|
357 |
1470
|
Luisehahne
|
require(ADMIN_PATH.'/interface/version.php');
|
358 |
1684
|
Luisehahne
|
|
359 |
1470
|
Luisehahne
|
$settings_rows= "INSERT INTO `".TABLE_PREFIX."settings` "
|
360 |
1818
|
Luisehahne
|
." (setting_id, name, value) VALUES "
|
361 |
|
|
." ( 1, 'wb_version', '".VERSION."'),"
|
362 |
|
|
." ( 2, 'website_title', '$website_title'),"
|
363 |
|
|
." ( 3, 'website_description', ''),"
|
364 |
|
|
." ( 4, 'website_keywords', ''),"
|
365 |
|
|
." ( 5, 'website_header', ''),"
|
366 |
|
|
." ( 6, 'website_footer', ''),"
|
367 |
|
|
." ( 7, 'wysiwyg_style', 'font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px;'),"
|
368 |
|
|
." ( 8, 'rename_files_on_upload', 'ph.*?,cgi,pl,pm,exe,com,bat,pif,cmd,src,asp,aspx,js,txt'),"
|
369 |
|
|
." ( 9, 'er_level', '0'),"
|
370 |
|
|
." (10, 'default_language', '$default_language'),"
|
371 |
|
|
." (11, 'app_name', 'wb_$session_rand'),"
|
372 |
|
|
." (12, 'sec_anchor', 'section_'),"
|
373 |
|
|
." (13, 'default_timezone', '$default_timezone'),"
|
374 |
1842
|
Luisehahne
|
." (14, 'default_date_format', 'Y-m-d'),"
|
375 |
1818
|
Luisehahne
|
." (15, 'default_time_format', 'h:i A'),"
|
376 |
|
|
." (16, 'redirect_timer', '1500'),"
|
377 |
|
|
." (17, 'home_folders', 'true'),"
|
378 |
|
|
." (18, 'warn_page_leave', '1'),"
|
379 |
|
|
." (19, 'default_template', 'round'),"
|
380 |
|
|
." (20, 'default_theme', 'wb_theme'),"
|
381 |
|
|
." (21, 'default_charset', 'utf-8'),"
|
382 |
|
|
." (22, 'multiple_menus', 'true'),"
|
383 |
|
|
." (23, 'page_level_limit', '6'),"
|
384 |
|
|
." (24, 'intro_page', 'false'),"
|
385 |
|
|
." (25, 'page_trash', 'inline'),"
|
386 |
|
|
." (26, 'homepage_redirection', 'false'),"
|
387 |
|
|
." (27, 'page_languages', 'true'),"
|
388 |
|
|
." (28, 'wysiwyg_editor', 'fckeditor'),"
|
389 |
|
|
." (29, 'manage_sections', 'true'),"
|
390 |
|
|
." (30, 'section_blocks', 'false'),"
|
391 |
|
|
." (31, 'smart_login', 'false'),"
|
392 |
|
|
." (32, 'frontend_login', 'false'),"
|
393 |
|
|
." (33, 'frontend_signup', 'false'),"
|
394 |
|
|
." (34, 'search', 'public'),"
|
395 |
|
|
." (35, 'page_extension', '.php'),"
|
396 |
|
|
." (36, 'page_spacer', '-'),"
|
397 |
|
|
." (37, 'pages_directory', '/pages'),"
|
398 |
|
|
." (38, 'rename_files_on_upload', 'ph.*?,cgi,pl,pm,exe,com,bat,pif,cmd,src,asp,aspx,js,txt'),"
|
399 |
|
|
." (39, 'media_directory', '/media'),"
|
400 |
|
|
." (40, 'operating_system', '$operating_system'),"
|
401 |
|
|
." (41, 'string_file_mode', '$file_mode'),"
|
402 |
|
|
." (42, 'string_dir_mode', '$dir_mode'),"
|
403 |
|
|
." (43, 'wbmailer_routine', 'phpmail'),"
|
404 |
|
|
." (44, 'server_email', '$admin_email'),"
|
405 |
|
|
." (45, 'wbmailer_default_sendername', 'WebsiteBaker Mailer'),"
|
406 |
|
|
." (46, 'wbmailer_smtp_host', ''),"
|
407 |
|
|
." (47, 'wbmailer_smtp_auth', ''),"
|
408 |
|
|
." (48, 'wbmailer_smtp_username', ''),"
|
409 |
|
|
." (49, 'wbmailer_smtp_password', ''),"
|
410 |
|
|
." (50, 'fingerprint_with_ip_octets', '2'),"
|
411 |
|
|
." (51, 'secure_form_module', ''),"
|
412 |
|
|
." (52, 'mediasettings', ''),"
|
413 |
|
|
." (53, 'wb_revision', '".REVISION."'),"
|
414 |
|
|
." (54, 'wb_sp', '".SP."'),"
|
415 |
|
|
." (55, 'page_icon_dir', '/templates/*/title_images'),"
|
416 |
|
|
." (56, 'dev_infos', 'false'),"
|
417 |
|
|
." (57, 'groups_updated', '".time()."'),"
|
418 |
1844
|
Luisehahne
|
." (58, 'wbmail_signature', ''),"
|
419 |
1818
|
Luisehahne
|
." (59, 'confirmed_registration', '1'),"
|
420 |
1849
|
Luisehahne
|
." (60, 'page_extendet', 'true'),"
|
421 |
1818
|
Luisehahne
|
." (61, 'modules_upgrade_list', 'news,wysiwyg,form'),"
|
422 |
|
|
." (62, 'system_locked', '0')";
|
423 |
1821
|
Luisehahne
|
if(!$database->query($settings_rows)) { set_error($database->get_error()); }
|
424 |
1684
|
Luisehahne
|
|
425 |
1822
|
Luisehahne
|
// Admin group
|
426 |
|
|
$full_system_permissions = 'access,addons,admintools,admintools_view,groups,groups_add,groups_delete,groups_modify,groups_view,';
|
427 |
|
|
$full_system_permissions .= 'languages,languages_install,languages_uninstall,languages_view,media,media_create,media_delete,media_rename,media_upload,media_view,';
|
428 |
|
|
$full_system_permissions .= 'modules,modules_advanced,modules_install,modules_uninstall,modules_view,pages,pages_add,pages_add_l0,pages_delete,pages_intro,pages_modify,pages_settings,pages_view,';
|
429 |
|
|
$full_system_permissions .= 'preferences,preferences_view,settings,settings_advanced,settings_basic,settings_view,templates,templates_install,templates_uninstall,templates_view,users,users_add,users_delete,users_modify,users_view';
|
430 |
|
|
$insert_admin_group = "INSERT INTO `".TABLE_PREFIX."groups` VALUES ('1', 'Administrators', '$full_system_permissions', '', '')";
|
431 |
|
|
if(!$database->query($insert_admin_group)) { set_error($database->get_error()); }
|
432 |
|
|
|
433 |
1821
|
Luisehahne
|
// Admin user
|
434 |
|
|
$insert_admin_user = "INSERT INTO `".TABLE_PREFIX."users` VALUES (1, 1, '1', 1, '$admin_username', '".md5($admin_password)."', '', 0, '', 0, 'Administrator', '$admin_email', 0, '', '', '$default_language', '', 0, '');";
|
435 |
|
|
if(!$database->query($insert_admin_user)) { set_error($database->get_error()); }
|
436 |
1684
|
Luisehahne
|
|
437 |
1822
|
Luisehahne
|
// Search layout default data
|
438 |
|
|
$sSqlFileName = dirname(__FILE__).'/sql/wb_search_data.sql';
|
439 |
1821
|
Luisehahne
|
if(!$database->SqlImport($sSqlFileName,TABLE_PREFIX, false)) { set_error($database->get_error()); }
|
440 |
1684
|
Luisehahne
|
|
441 |
1821
|
Luisehahne
|
// Include WB functions file
|
442 |
|
|
require_once(WB_PATH.'/framework/functions.php');
|
443 |
|
|
// Re-connect to the database, this time using in-build database class
|
444 |
|
|
require_once(WB_PATH.'/framework/class.login.php');
|
445 |
1684
|
Luisehahne
|
|
446 |
1470
|
Luisehahne
|
require_once(WB_PATH.'/framework/initialize.php');
|
447 |
|
|
// Include the PclZip class file (thanks to
|
448 |
|
|
require_once(WB_PATH.'/include/pclzip/pclzip.lib.php');
|
449 |
|
|
// Install add-ons
|
450 |
|
|
if(file_exists(WB_PATH.'/install/modules')) {
|
451 |
|
|
// Unpack pre-packaged modules
|
452 |
|
|
}
|
453 |
|
|
if(file_exists(WB_PATH.'/install/templates')) {
|
454 |
|
|
// Unpack pre-packaged templates
|
455 |
|
|
}
|
456 |
|
|
if(file_exists(WB_PATH.'/install/languages')) {
|
457 |
|
|
// Unpack pre-packaged languages
|
458 |
|
|
}
|
459 |
1734
|
Luisehahne
|
|
460 |
1529
|
Luisehahne
|
$admin=new admin_dummy('Start','',false,false);
|
461 |
1470
|
Luisehahne
|
// Load addons into DB
|
462 |
|
|
$dirs['modules'] = WB_PATH.'/modules/';
|
463 |
|
|
$dirs['templates'] = WB_PATH.'/templates/';
|
464 |
|
|
$dirs['languages'] = WB_PATH.'/languages/';
|
465 |
1540
|
Luisehahne
|
|
466 |
1470
|
Luisehahne
|
foreach($dirs AS $type => $dir) {
|
467 |
1686
|
darkviper
|
if(($handle = opendir($dir))) {
|
468 |
1470
|
Luisehahne
|
while(false !== ($file = readdir($handle))) {
|
469 |
|
|
if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'admin.php' AND $file != 'index.php') {
|
470 |
|
|
// Get addon type
|
471 |
|
|
if($type == 'modules') {
|
472 |
|
|
load_module($dir.'/'.$file, true);
|
473 |
|
|
// Pretty ugly hack to let modules run $admin->set_error
|
474 |
|
|
// See dummy class definition admin_dummy above
|
475 |
|
|
if ($admin->error!='') {
|
476 |
|
|
set_error($admin->error);
|
477 |
|
|
}
|
478 |
|
|
} elseif($type == 'templates') {
|
479 |
|
|
load_template($dir.'/'.$file);
|
480 |
|
|
} elseif($type == 'languages') {
|
481 |
|
|
load_language($dir.'/'.$file);
|
482 |
|
|
}
|
483 |
|
|
}
|
484 |
|
|
}
|
485 |
1686
|
darkviper
|
closedir($handle);
|
486 |
1470
|
Luisehahne
|
}
|
487 |
|
|
}
|
488 |
1684
|
Luisehahne
|
|
489 |
1821
|
Luisehahne
|
// Check if there was a database error
|
490 |
1470
|
Luisehahne
|
if($database->is_error()) {
|
491 |
|
|
set_error($database->get_error());
|
492 |
|
|
}
|
493 |
|
|
|
494 |
1821
|
Luisehahne
|
if ( sizeof(createFolderProtectFile( WB_PATH.MEDIA_DIRECTORY )) ) { }
|
495 |
|
|
if ( sizeof(createFolderProtectFile( WB_PATH.MEDIA_DIRECTORY.'/home' )) ) { }
|
496 |
|
|
if ( sizeof(createFolderProtectFile( WB_PATH.PAGES_DIRECTORY )) ) { }
|
497 |
1818
|
Luisehahne
|
|
498 |
1684
|
Luisehahne
|
// end of if install_tables
|
499 |
|
|
|
500 |
1529
|
Luisehahne
|
$ThemeUrl = WB_URL.$admin->correct_theme_source('warning.html');
|
501 |
|
|
// Setup template object, parse vars to it, then parse it
|
502 |
1722
|
Luisehahne
|
$ThemePath = realpath(WB_PATH.$admin->correct_theme_source('loginBox.htt'));
|
503 |
1529
|
Luisehahne
|
|
504 |
1470
|
Luisehahne
|
// Log the user in and go to Website Baker Administration
|
505 |
|
|
$thisApp = new Login(
|
506 |
1821
|
Luisehahne
|
array(
|
507 |
|
|
"MAX_ATTEMPS" => "50",
|
508 |
|
|
"WARNING_URL" => $ThemeUrl."/warning.html",
|
509 |
|
|
"USERNAME_FIELDNAME" => 'admin_username',
|
510 |
|
|
"PASSWORD_FIELDNAME" => 'admin_password',
|
511 |
|
|
"REMEMBER_ME_OPTION" => SMART_LOGIN,
|
512 |
|
|
"MIN_USERNAME_LEN" => "2",
|
513 |
|
|
"MIN_PASSWORD_LEN" => "3",
|
514 |
|
|
"MAX_USERNAME_LEN" => "30",
|
515 |
|
|
"MAX_PASSWORD_LEN" => "30",
|
516 |
|
|
'LOGIN_URL' => ADMIN_URL."/login/index.php",
|
517 |
|
|
'DEFAULT_URL' => ADMIN_URL."/start/index.php",
|
518 |
|
|
'TEMPLATE_DIR' => $ThemePath,
|
519 |
|
|
'TEMPLATE_FILE' => 'loginBox.htt',
|
520 |
|
|
'FRONTEND' => false,
|
521 |
|
|
'FORGOTTEN_DETAILS_APP' => ADMIN_URL."/login/forgot/index.php",
|
522 |
|
|
'USERS_TABLE' => TABLE_PREFIX."users",
|
523 |
|
|
'GROUPS_TABLE' => TABLE_PREFIX."groups",
|
524 |
|
|
)
|
525 |
1470
|
Luisehahne
|
);
|