1 |
1470
|
Luisehahne
|
<?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 |
1529
|
Luisehahne
|
/* */
|
85 |
1470
|
Luisehahne
|
|
86 |
|
|
// Function to workout what the default permissions are for files created by the webserver
|
87 |
|
|
function default_file_mode($temp_dir) {
|
88 |
|
|
$v = explode(".",PHP_VERSION);
|
89 |
|
|
$v = $v[0].$v[1];
|
90 |
|
|
if($v > 41 AND is_writable($temp_dir)) {
|
91 |
|
|
$filename = $temp_dir.'/test_permissions.txt';
|
92 |
|
|
$handle = fopen($filename, 'w');
|
93 |
|
|
fwrite($handle, 'This file is to get the default file permissions');
|
94 |
|
|
fclose($handle);
|
95 |
|
|
$default_file_mode = '0'.substr(sprintf('%o', fileperms($filename)), -3);
|
96 |
|
|
unlink($filename);
|
97 |
|
|
} else {
|
98 |
|
|
$default_file_mode = '0777';
|
99 |
|
|
}
|
100 |
|
|
return $default_file_mode;
|
101 |
|
|
}
|
102 |
|
|
|
103 |
|
|
// Function to workout what the default permissions are for directories created by the webserver
|
104 |
|
|
function default_dir_mode($temp_dir) {
|
105 |
|
|
$v = explode(".",PHP_VERSION);
|
106 |
|
|
$v = $v[0].$v[1];
|
107 |
|
|
if($v > 41 AND is_writable($temp_dir)) {
|
108 |
|
|
$dirname = $temp_dir.'/test_permissions/';
|
109 |
|
|
mkdir($dirname);
|
110 |
|
|
$default_dir_mode = '0'.substr(sprintf('%o', fileperms($dirname)), -3);
|
111 |
|
|
rmdir($dirname);
|
112 |
|
|
} else {
|
113 |
|
|
$default_dir_mode = '0777';
|
114 |
|
|
}
|
115 |
|
|
return $default_dir_mode;
|
116 |
|
|
}
|
117 |
|
|
|
118 |
|
|
function add_slashes($input) {
|
119 |
|
|
if ( get_magic_quotes_gpc() || ( !is_string($input) ) ) {
|
120 |
|
|
return $input;
|
121 |
|
|
}
|
122 |
|
|
$output = addslashes($input);
|
123 |
|
|
return $output;
|
124 |
|
|
}
|
125 |
|
|
|
126 |
|
|
// Begin check to see if form was even submitted
|
127 |
|
|
// Set error if no post vars found
|
128 |
|
|
if(!isset($_POST['website_title'])) {
|
129 |
|
|
set_error('Please fill-in the form below');
|
130 |
|
|
}
|
131 |
|
|
// End check to see if form was even submitted
|
132 |
|
|
|
133 |
|
|
// Begin path and timezone details code
|
134 |
|
|
|
135 |
|
|
// Check if user has entered the installation url
|
136 |
|
|
if(!isset($_POST['wb_url']) OR $_POST['wb_url'] == '') {
|
137 |
|
|
set_error('Please enter an absolute URL', 'wb_url');
|
138 |
|
|
} else {
|
139 |
|
|
$wb_url = $_POST['wb_url'];
|
140 |
|
|
}
|
141 |
|
|
// Remove any slashes at the end of the URL
|
142 |
|
|
if(substr($wb_url, strlen($wb_url)-1, 1) == "/") {
|
143 |
|
|
$wb_url = substr($wb_url, 0, strlen($wb_url)-1);
|
144 |
|
|
}
|
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 |
|
|
// Get the default time zone
|
155 |
|
|
if(!isset($_POST['default_timezone']) OR !is_numeric($_POST['default_timezone'])) {
|
156 |
|
|
set_error('Please select a valid default timezone', 'default_timezone');
|
157 |
|
|
} else {
|
158 |
|
|
$default_timezone = $_POST['default_timezone']*60*60;
|
159 |
|
|
}
|
160 |
|
|
// End path and timezone details code
|
161 |
|
|
|
162 |
|
|
// Get the default language
|
163 |
|
|
$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');
|
164 |
|
|
if(!isset($_POST['default_language']) OR !in_array($_POST['default_language'], $allowed_languages)) {
|
165 |
|
|
set_error('Please select a valid default backend language','default_language');
|
166 |
|
|
} else {
|
167 |
|
|
$default_language = $_POST['default_language'];
|
168 |
|
|
// make sure the selected language file exists in the language folder
|
169 |
|
|
if(!file_exists('../languages/' .$default_language .'.php')) {
|
170 |
|
|
set_error('The language file: \'' .$default_language .'.php\' is missing. Upload file to language folder or choose another language','default_language');
|
171 |
|
|
}
|
172 |
|
|
}
|
173 |
|
|
// End default language details code
|
174 |
|
|
|
175 |
|
|
// Begin operating system specific code
|
176 |
|
|
// Get operating system
|
177 |
|
|
if(!isset($_POST['operating_system']) OR $_POST['operating_system'] != 'linux' AND $_POST['operating_system'] != 'windows') {
|
178 |
|
|
set_error('Please select a valid operating system');
|
179 |
|
|
} else {
|
180 |
|
|
$operating_system = $_POST['operating_system'];
|
181 |
|
|
}
|
182 |
|
|
// Work-out file permissions
|
183 |
|
|
if($operating_system == 'windows') {
|
184 |
|
|
$file_mode = '0777';
|
185 |
|
|
$dir_mode = '0777';
|
186 |
|
|
} elseif(isset($_POST['world_writeable']) AND $_POST['world_writeable'] == 'true') {
|
187 |
|
|
$file_mode = '0777';
|
188 |
|
|
$dir_mode = '0777';
|
189 |
|
|
} else {
|
190 |
|
|
$file_mode = default_file_mode('../temp');
|
191 |
|
|
$dir_mode = default_dir_mode('../temp');
|
192 |
|
|
}
|
193 |
|
|
// End operating system specific code
|
194 |
|
|
|
195 |
|
|
// Begin database details code
|
196 |
|
|
// Check if user has entered a database host
|
197 |
|
|
if(!isset($_POST['database_host']) OR $_POST['database_host'] == '') {
|
198 |
|
|
set_error('Please enter a database host name', 'database_host');
|
199 |
|
|
} else {
|
200 |
|
|
$database_host = $_POST['database_host'];
|
201 |
|
|
}
|
202 |
|
|
// Check if user has entered a database username
|
203 |
|
|
if(!isset($_POST['database_username']) OR $_POST['database_username'] == '') {
|
204 |
|
|
set_error('Please enter a database username','database_username');
|
205 |
|
|
} else {
|
206 |
|
|
$database_username = $_POST['database_username'];
|
207 |
|
|
}
|
208 |
|
|
// Check if user has entered a database password
|
209 |
|
|
if(!isset($_POST['database_password'])) {
|
210 |
|
|
set_error('Please enter a database password', 'database_password');
|
211 |
|
|
} else {
|
212 |
|
|
$database_password = $_POST['database_password'];
|
213 |
|
|
}
|
214 |
|
|
// Check if user has entered a database name
|
215 |
|
|
if(!isset($_POST['database_name']) OR $_POST['database_name'] == '') {
|
216 |
|
|
set_error('Please enter a database name', 'database_name');
|
217 |
|
|
} else {
|
218 |
|
|
// make sure only allowed characters are specified
|
219 |
|
|
if(preg_match('/[^a-z0-9_-]+/i', $_POST['database_name'])) {
|
220 |
|
|
// contains invalid characters (only a-z, A-Z, 0-9 and _ allowed to avoid problems with table/field names)
|
221 |
|
|
set_error('Only characters a-z, A-Z, 0-9, - and _ allowed in database name.', 'database_name');
|
222 |
|
|
}
|
223 |
|
|
$database_name = $_POST['database_name'];
|
224 |
|
|
}
|
225 |
|
|
// Get table prefix
|
226 |
|
|
if(preg_match('/[^a-z0-9_]+/i', $_POST['table_prefix'])) {
|
227 |
|
|
// contains invalid characters (only a-z, A-Z, 0-9 and _ allowed to avoid problems with table/field names)
|
228 |
|
|
set_error('Only characters a-z, A-Z, 0-9 and _ allowed in table_prefix.', 'table_prefix');
|
229 |
|
|
} else {
|
230 |
|
|
$table_prefix = $_POST['table_prefix'];
|
231 |
|
|
}
|
232 |
|
|
|
233 |
|
|
// Find out if the user wants to install tables and data
|
234 |
|
|
if(isset($_POST['install_tables']) AND $_POST['install_tables'] == 'true') {
|
235 |
|
|
$install_tables = true;
|
236 |
|
|
} else {
|
237 |
|
|
$install_tables = false;
|
238 |
|
|
}
|
239 |
|
|
// 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 |
|
|
"define('DB_TYPE', 'mysql');\n".
|
288 |
|
|
"define('DB_HOST', '$database_host');\n".
|
289 |
1529
|
Luisehahne
|
"define('DB_NAME', '$database_name');\n".
|
290 |
1470
|
Luisehahne
|
"define('DB_USERNAME', '$database_username');\n".
|
291 |
|
|
"define('DB_PASSWORD', '$database_password');\n".
|
292 |
|
|
"define('TABLE_PREFIX', '$table_prefix');\n".
|
293 |
|
|
"\n".
|
294 |
|
|
"define('WB_URL', '$wb_url');\n".
|
295 |
1638
|
darkviper
|
"define('ADMIN_DIRECTORY', 'admin'); // no leading/trailing slash or backslash!! A simple directory only!!\n".
|
296 |
1470
|
Luisehahne
|
"\n".
|
297 |
1637
|
darkviper
|
"require_once(dirname(__FILE__).'/framework/initialize.php');\n".
|
298 |
|
|
"\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 |
|
|
define('DB_TYPE', 'mysql');
|
318 |
|
|
define('DB_HOST', $database_host);
|
319 |
1529
|
Luisehahne
|
define('DB_NAME', $database_name);
|
320 |
1470
|
Luisehahne
|
define('DB_USERNAME', $database_username);
|
321 |
|
|
define('DB_PASSWORD', $database_password);
|
322 |
|
|
define('TABLE_PREFIX', $table_prefix);
|
323 |
|
|
define('WB_PATH', str_replace(array('/install','\install'), '',dirname(__FILE__)));
|
324 |
|
|
define('WB_URL', $wb_url);
|
325 |
|
|
define('ADMIN_PATH', WB_PATH.'/admin');
|
326 |
|
|
define('ADMIN_URL', $wb_url.'/admin');
|
327 |
|
|
|
328 |
|
|
// Check if the user has entered a correct path
|
329 |
|
|
if(!file_exists(WB_PATH.'/framework/class.admin.php')) {
|
330 |
|
|
set_error('It appears the Absolute path that you entered is incorrect');
|
331 |
|
|
}
|
332 |
|
|
|
333 |
|
|
// Try connecting to database
|
334 |
|
|
if(!@mysql_connect(DB_HOST, DB_USERNAME, DB_PASSWORD)) {
|
335 |
|
|
set_error('Database host name, username and/or password incorrect. MySQL Error:<br />'.mysql_error());
|
336 |
|
|
}
|
337 |
|
|
|
338 |
|
|
// Try to create the database
|
339 |
|
|
mysql_query('CREATE DATABASE `'.$database_name.'`');
|
340 |
|
|
|
341 |
|
|
// Close the mysql connection
|
342 |
|
|
mysql_close();
|
343 |
|
|
|
344 |
|
|
$sSecMod = (defined('SECURE_FORM_MODULE') && SECURE_FORM_MODULE != '') ? '.'.SECURE_FORM_MODULE : '';
|
345 |
|
|
$sSecMod = WB_PATH.'/framework/SecureForm'.$sSecMod.'.php';
|
346 |
|
|
require_once($sSecMod);
|
347 |
|
|
|
348 |
1529
|
Luisehahne
|
require_once(WB_PATH.'/framework/class.admin.php');
|
349 |
|
|
|
350 |
|
|
// Dummy class to allow modules' install scripts to call $admin->print_error
|
351 |
|
|
class admin_dummy extends admin
|
352 |
|
|
{
|
353 |
|
|
var $error='';
|
354 |
1633
|
darkviper
|
function print_error($message, $link = 'index.php', $auto_footer = true)
|
355 |
1529
|
Luisehahne
|
{
|
356 |
|
|
$this->error=$message;
|
357 |
|
|
}
|
358 |
|
|
}
|
359 |
|
|
|
360 |
1470
|
Luisehahne
|
// Include WB functions file
|
361 |
|
|
require_once(WB_PATH.'/framework/functions.php');
|
362 |
|
|
|
363 |
|
|
// Re-connect to the database, this time using in-build database class
|
364 |
|
|
require_once(WB_PATH.'/framework/class.login.php');
|
365 |
1529
|
Luisehahne
|
|
366 |
1470
|
Luisehahne
|
$database=new database();
|
367 |
|
|
|
368 |
|
|
// Check if we should install tables
|
369 |
|
|
if($install_tables == true) {
|
370 |
|
|
if (!defined('WB_INSTALL_PROCESS')) define ('WB_INSTALL_PROCESS', true);
|
371 |
|
|
// Remove tables if they exist
|
372 |
|
|
|
373 |
|
|
// Pages table
|
374 |
|
|
$pages = "DROP TABLE IF EXISTS `".TABLE_PREFIX."pages`";
|
375 |
|
|
$database->query($pages);
|
376 |
|
|
// Sections table
|
377 |
|
|
$sections = "DROP TABLE IF EXISTS `".TABLE_PREFIX."sections`";
|
378 |
|
|
$database->query($sections);
|
379 |
|
|
// Settings table
|
380 |
|
|
$settings = "DROP TABLE IF EXISTS `".TABLE_PREFIX."settings`";
|
381 |
|
|
$database->query($settings);
|
382 |
|
|
// Users table
|
383 |
|
|
$users = "DROP TABLE IF EXISTS `".TABLE_PREFIX."users`";
|
384 |
|
|
$database->query($users);
|
385 |
|
|
// Groups table
|
386 |
|
|
$groups = "DROP TABLE IF EXISTS `".TABLE_PREFIX."groups`";
|
387 |
|
|
$database->query($groups);
|
388 |
|
|
// Search table
|
389 |
|
|
$search = "DROP TABLE IF EXISTS `".TABLE_PREFIX."search`";
|
390 |
|
|
$database->query($search);
|
391 |
|
|
// Addons table
|
392 |
|
|
$addons = "DROP TABLE IF EXISTS `".TABLE_PREFIX."addons`";
|
393 |
|
|
$database->query($addons);
|
394 |
|
|
|
395 |
|
|
// Try installing tables
|
396 |
|
|
|
397 |
|
|
// Pages table
|
398 |
|
|
$pages = 'CREATE TABLE `'.TABLE_PREFIX.'pages` ( `page_id` INT NOT NULL auto_increment,'
|
399 |
|
|
. ' `parent` INT NOT NULL DEFAULT \'0\','
|
400 |
|
|
. ' `root_parent` INT NOT NULL DEFAULT \'0\','
|
401 |
|
|
. ' `level` INT NOT NULL DEFAULT \'0\','
|
402 |
|
|
. ' `link` TEXT NOT NULL,'
|
403 |
|
|
. ' `target` VARCHAR( 7 ) NOT NULL DEFAULT \'\' ,'
|
404 |
|
|
. ' `page_title` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
405 |
|
|
. ' `menu_title` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
406 |
|
|
. ' `description` TEXT NOT NULL ,'
|
407 |
|
|
. ' `keywords` TEXT NOT NULL ,'
|
408 |
|
|
. ' `page_trail` TEXT NOT NULL ,'
|
409 |
|
|
. ' `template` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
410 |
|
|
. ' `visibility` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
411 |
|
|
. ' `position` INT NOT NULL DEFAULT \'0\','
|
412 |
|
|
. ' `menu` INT NOT NULL DEFAULT \'0\','
|
413 |
|
|
. ' `language` VARCHAR( 5 ) NOT NULL DEFAULT \'\' ,'
|
414 |
|
|
. ' `searching` INT NOT NULL DEFAULT \'0\','
|
415 |
|
|
. ' `admin_groups` TEXT NOT NULL ,'
|
416 |
|
|
. ' `admin_users` TEXT NOT NULL ,'
|
417 |
|
|
. ' `viewing_groups` TEXT NOT NULL ,'
|
418 |
|
|
. ' `viewing_users` TEXT NOT NULL ,'
|
419 |
|
|
. ' `modified_when` INT NOT NULL DEFAULT \'0\','
|
420 |
|
|
. ' `modified_by` INT NOT NULL DEFAULT \'0\','
|
421 |
|
|
. ' PRIMARY KEY ( `page_id` ) '
|
422 |
1529
|
Luisehahne
|
. ' ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci';
|
423 |
1470
|
Luisehahne
|
$database->query($pages);
|
424 |
|
|
|
425 |
|
|
// Sections table
|
426 |
|
|
$pages = 'CREATE TABLE `'.TABLE_PREFIX.'sections` ( `section_id` INT NOT NULL auto_increment,'
|
427 |
|
|
. ' `page_id` INT NOT NULL DEFAULT \'0\','
|
428 |
|
|
. ' `position` INT NOT NULL DEFAULT \'0\','
|
429 |
|
|
. ' `module` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
430 |
|
|
. ' `block` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
431 |
|
|
. ' `publ_start` VARCHAR( 255 ) NOT NULL DEFAULT \'0\' ,'
|
432 |
|
|
. ' `publ_end` VARCHAR( 255 ) NOT NULL DEFAULT \'0\' ,'
|
433 |
|
|
. ' PRIMARY KEY ( `section_id` ) '
|
434 |
1529
|
Luisehahne
|
. ' ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci';
|
435 |
1470
|
Luisehahne
|
$database->query($pages);
|
436 |
|
|
|
437 |
|
|
require(ADMIN_PATH.'/interface/version.php');
|
438 |
|
|
|
439 |
|
|
// Settings table
|
440 |
|
|
$settings='CREATE TABLE `'.TABLE_PREFIX.'settings` ( `setting_id` INT NOT NULL auto_increment,'
|
441 |
|
|
. ' `name` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
442 |
|
|
. ' `value` TEXT NOT NULL ,'
|
443 |
|
|
. ' PRIMARY KEY ( `setting_id` ) '
|
444 |
1529
|
Luisehahne
|
. ' ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci';
|
445 |
1470
|
Luisehahne
|
$database->query($settings);
|
446 |
|
|
|
447 |
|
|
$settings_rows= "INSERT INTO `".TABLE_PREFIX."settings` "
|
448 |
|
|
." (name, value) VALUES "
|
449 |
|
|
." ('wb_version', '".VERSION."'),"
|
450 |
1532
|
Luisehahne
|
." ('wb_revision', '".REVISION."'),"
|
451 |
|
|
." ('wb_sp', '".SP."'),"
|
452 |
1470
|
Luisehahne
|
." ('website_title', '$website_title'),"
|
453 |
|
|
." ('website_description', ''),"
|
454 |
|
|
." ('website_keywords', ''),"
|
455 |
|
|
." ('website_header', ''),"
|
456 |
|
|
." ('website_footer', ''),"
|
457 |
|
|
." ('wysiwyg_style', 'font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px;'),"
|
458 |
|
|
." ('er_level', ''),"
|
459 |
|
|
." ('default_language', '$default_language'),"
|
460 |
|
|
." ('app_name', 'wb_$session_rand'),"
|
461 |
|
|
." ('sec_anchor', 'wb_'),"
|
462 |
|
|
." ('default_timezone', '$default_timezone'),"
|
463 |
|
|
." ('default_date_format', 'M d Y'),"
|
464 |
|
|
." ('default_time_format', 'g:i A'),"
|
465 |
|
|
." ('redirect_timer', '1500'),"
|
466 |
|
|
." ('home_folders', 'true'),"
|
467 |
|
|
." ('warn_page_leave', '1'),"
|
468 |
|
|
." ('default_template', 'round'),"
|
469 |
|
|
." ('default_theme', 'wb_theme'),"
|
470 |
|
|
." ('default_charset', 'utf-8'),"
|
471 |
|
|
." ('multiple_menus', 'true'),"
|
472 |
|
|
." ('page_level_limit', '4'),"
|
473 |
|
|
." ('intro_page', 'false'),"
|
474 |
|
|
." ('page_trash', 'inline'),"
|
475 |
|
|
." ('homepage_redirection', 'false'),"
|
476 |
|
|
." ('page_languages', 'true'),"
|
477 |
|
|
." ('wysiwyg_editor', 'fckeditor'),"
|
478 |
|
|
." ('manage_sections', 'true'),"
|
479 |
|
|
." ('section_blocks', 'true'),"
|
480 |
|
|
." ('smart_login', 'true'),"
|
481 |
|
|
." ('frontend_login', 'false'),"
|
482 |
|
|
." ('frontend_signup', 'false'),"
|
483 |
|
|
." ('search', 'public'),"
|
484 |
|
|
." ('page_extension', '.php'),"
|
485 |
|
|
." ('page_spacer', '-'),"
|
486 |
|
|
." ('pages_directory', '/pages'),"
|
487 |
1476
|
Luisehahne
|
." ('rename_files_on_upload', 'ph.*?,cgi,pl,pm,exe,com,bat,pif,cmd,src,asp,aspx'),"
|
488 |
1470
|
Luisehahne
|
." ('media_directory', '/media'),"
|
489 |
|
|
." ('operating_system', '$operating_system'),"
|
490 |
|
|
." ('string_file_mode', '$file_mode'),"
|
491 |
|
|
." ('string_dir_mode', '$dir_mode'),"
|
492 |
|
|
." ('wbmailer_routine', 'phpmail'),"
|
493 |
1549
|
Luisehahne
|
." ('server_email', '$admin_email')," // avoid that mail provider (e.g. mail.com) reject mails like yourname@mail.com
|
494 |
1470
|
Luisehahne
|
." ('wbmailer_default_sendername', 'WB Mailer'),"
|
495 |
|
|
." ('wbmailer_smtp_host', ''),"
|
496 |
|
|
." ('wbmailer_smtp_auth', ''),"
|
497 |
|
|
." ('wbmailer_smtp_username', ''),"
|
498 |
|
|
." ('wbmailer_smtp_password', ''),"
|
499 |
1568
|
Luisehahne
|
." ('fingerprint_with_ip_octets', '2'),"
|
500 |
1476
|
Luisehahne
|
." ('secure_form_module', ''),"
|
501 |
1470
|
Luisehahne
|
." ('mediasettings', '')";
|
502 |
|
|
$database->query($settings_rows);
|
503 |
|
|
|
504 |
|
|
// Users table
|
505 |
|
|
$users = 'CREATE TABLE `'.TABLE_PREFIX.'users` ( `user_id` INT NOT NULL auto_increment,'
|
506 |
|
|
. ' `group_id` INT NOT NULL DEFAULT \'0\','
|
507 |
|
|
. ' `groups_id` VARCHAR( 255 ) NOT NULL DEFAULT \'0\','
|
508 |
|
|
. ' `active` INT NOT NULL DEFAULT \'0\','
|
509 |
|
|
. ' `username` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
510 |
|
|
. ' `password` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
511 |
|
|
. ' `remember_key` VARCHAR( 255 ) NOT NULL DEFAULT \'\','
|
512 |
|
|
. ' `last_reset` INT NOT NULL DEFAULT \'0\','
|
513 |
|
|
. ' `display_name` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
514 |
|
|
. ' `email` TEXT NOT NULL ,'
|
515 |
|
|
. ' `timezone` INT NOT NULL DEFAULT \'0\','
|
516 |
|
|
. ' `date_format` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
517 |
|
|
. ' `time_format` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
518 |
|
|
. ' `language` VARCHAR( 5 ) NOT NULL DEFAULT \'' .$default_language .'\' ,'
|
519 |
|
|
. ' `home_folder` TEXT NOT NULL ,'
|
520 |
|
|
. ' `login_when` INT NOT NULL DEFAULT \'0\','
|
521 |
|
|
. ' `login_ip` VARCHAR( 15 ) NOT NULL DEFAULT \'\' ,'
|
522 |
|
|
. ' PRIMARY KEY ( `user_id` ) '
|
523 |
1529
|
Luisehahne
|
. ' ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci';
|
524 |
1470
|
Luisehahne
|
$database->query($users);
|
525 |
|
|
|
526 |
|
|
// Groups table
|
527 |
|
|
$groups = 'CREATE TABLE `'.TABLE_PREFIX.'groups` ( `group_id` INT NOT NULL auto_increment,'
|
528 |
|
|
. ' `name` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
529 |
|
|
. ' `system_permissions` TEXT NOT NULL ,'
|
530 |
|
|
. ' `module_permissions` TEXT NOT NULL ,'
|
531 |
|
|
. ' `template_permissions` TEXT NOT NULL ,'
|
532 |
|
|
. ' PRIMARY KEY ( `group_id` ) '
|
533 |
1529
|
Luisehahne
|
. ' ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci';
|
534 |
1470
|
Luisehahne
|
$database->query($groups);
|
535 |
|
|
|
536 |
|
|
// Search settings table
|
537 |
|
|
$search = 'CREATE TABLE `'.TABLE_PREFIX.'search` ( `search_id` INT NOT NULL auto_increment,'
|
538 |
|
|
. ' `name` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
539 |
|
|
. ' `value` TEXT NOT NULL ,'
|
540 |
|
|
. ' `extra` TEXT NOT NULL ,'
|
541 |
|
|
. ' PRIMARY KEY ( `search_id` ) '
|
542 |
1529
|
Luisehahne
|
. ' ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci';
|
543 |
1470
|
Luisehahne
|
$database->query($search);
|
544 |
|
|
|
545 |
|
|
// Addons table
|
546 |
|
|
$addons = 'CREATE TABLE `'.TABLE_PREFIX.'addons` ( '
|
547 |
|
|
.'`addon_id` INT NOT NULL auto_increment ,'
|
548 |
|
|
.'`type` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
549 |
|
|
.'`directory` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
550 |
|
|
.'`name` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
551 |
|
|
.'`description` TEXT NOT NULL ,'
|
552 |
|
|
.'`function` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
553 |
|
|
.'`version` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
554 |
|
|
.'`platform` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
555 |
|
|
.'`author` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
556 |
|
|
.'`license` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
557 |
|
|
.' PRIMARY KEY ( `addon_id` ) '
|
558 |
1529
|
Luisehahne
|
.' ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci';
|
559 |
1470
|
Luisehahne
|
$database->query($addons);
|
560 |
|
|
|
561 |
|
|
// Insert default data
|
562 |
|
|
|
563 |
|
|
// Admin group
|
564 |
|
|
$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';
|
565 |
|
|
$insert_admin_group = "INSERT INTO `".TABLE_PREFIX."groups` VALUES ('1', 'Administrators', '$full_system_permissions', '', '')";
|
566 |
|
|
$database->query($insert_admin_group);
|
567 |
|
|
// Admin user
|
568 |
|
|
$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')";
|
569 |
|
|
$database->query($insert_admin_user);
|
570 |
|
|
|
571 |
|
|
// Search header
|
572 |
|
|
$search_header = addslashes('
|
573 |
|
|
<h1>[TEXT_SEARCH]</h1>
|
574 |
|
|
|
575 |
|
|
<form name="searchpage" action="[WB_URL]/search/index.php" method="get">
|
576 |
|
|
<table cellpadding="3" cellspacing="0" border="0" width="500">
|
577 |
|
|
<tr>
|
578 |
|
|
<td>
|
579 |
|
|
<input type="hidden" name="search_path" value="[SEARCH_PATH]" />
|
580 |
|
|
<input type="text" name="string" value="[SEARCH_STRING]" style="width: 100%;" />
|
581 |
|
|
</td>
|
582 |
|
|
<td width="150">
|
583 |
|
|
<input type="submit" value="[TEXT_SEARCH]" style="width: 100%;" />
|
584 |
|
|
</td>
|
585 |
|
|
</tr>
|
586 |
|
|
<tr>
|
587 |
|
|
<td colspan="2">
|
588 |
|
|
<input type="radio" name="match" id="match_all" value="all"[ALL_CHECKED] />
|
589 |
|
|
<label for="match_all">[TEXT_ALL_WORDS]</label>
|
590 |
|
|
<input type="radio" name="match" id="match_any" value="any"[ANY_CHECKED] />
|
591 |
|
|
<label for="match_any">[TEXT_ANY_WORDS]</label>
|
592 |
|
|
<input type="radio" name="match" id="match_exact" value="exact"[EXACT_CHECKED] />
|
593 |
|
|
<label for="match_exact">[TEXT_EXACT_MATCH]</label>
|
594 |
|
|
</td>
|
595 |
|
|
</tr>
|
596 |
|
|
</table>
|
597 |
|
|
|
598 |
|
|
</form>
|
599 |
|
|
|
600 |
|
|
<hr />
|
601 |
|
|
');
|
602 |
|
|
$insert_search_header = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'header', '$search_header', '')";
|
603 |
|
|
$database->query($insert_search_header);
|
604 |
|
|
// Search footer
|
605 |
|
|
$search_footer = addslashes('');
|
606 |
|
|
$insert_search_footer = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'footer', '$search_footer', '')";
|
607 |
|
|
$database->query($insert_search_footer);
|
608 |
|
|
// Search results header
|
609 |
|
|
$search_results_header = addslashes(''.
|
610 |
|
|
'[TEXT_RESULTS_FOR] \'<b>[SEARCH_STRING]</b>\':
|
611 |
|
|
<table cellpadding="2" cellspacing="0" border="0" width="100%" style="padding-top: 10px;">');
|
612 |
|
|
$insert_search_results_header = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'results_header', '$search_results_header', '')";
|
613 |
|
|
$database->query($insert_search_results_header);
|
614 |
|
|
// Search results loop
|
615 |
|
|
$search_results_loop = addslashes(''.
|
616 |
|
|
'<tr style="background-color: #F0F0F0;">
|
617 |
|
|
<td><a href="[LINK]">[TITLE]</a></td>
|
618 |
|
|
<td align="right">[TEXT_LAST_UPDATED_BY] [DISPLAY_NAME] ([USERNAME]) [TEXT_ON] [DATE]</td>
|
619 |
|
|
</tr>
|
620 |
|
|
<tr><td colspan="2" style="text-align: justify; padding-bottom: 5px;">[DESCRIPTION]</td></tr>
|
621 |
|
|
<tr><td colspan="2" style="text-align: justify; padding-bottom: 10px;">[EXCERPT]</td></tr>');
|
622 |
|
|
|
623 |
|
|
$insert_search_results_loop = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'results_loop', '$search_results_loop', '')";
|
624 |
|
|
$database->query($insert_search_results_loop);
|
625 |
|
|
// Search results footer
|
626 |
|
|
$search_results_footer = addslashes("</table>");
|
627 |
|
|
$insert_search_results_footer = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'results_footer', '$search_results_footer', '')";
|
628 |
|
|
$database->query($insert_search_results_footer);
|
629 |
|
|
// Search no results
|
630 |
|
|
$search_no_results = addslashes('<tr><td><p>[TEXT_NO_RESULTS]</p></td></tr>');
|
631 |
|
|
$insert_search_no_results = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'no_results', '$search_no_results', '')";
|
632 |
|
|
$database->query($insert_search_no_results);
|
633 |
|
|
// Search module-order
|
634 |
|
|
$search_module_order = addslashes('faqbaker,manual,wysiwyg');
|
635 |
|
|
$insert_search_module_order = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'module_order', '$search_module_order', '')";
|
636 |
|
|
$database->query($insert_search_module_order);
|
637 |
|
|
// Search max lines of excerpt
|
638 |
|
|
$search_max_excerpt = addslashes('15');
|
639 |
|
|
$insert_search_max_excerpt = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'max_excerpt', '$search_max_excerpt', '')";
|
640 |
|
|
$database->query($insert_search_max_excerpt);
|
641 |
|
|
// max time to search per module
|
642 |
|
|
$search_time_limit = addslashes('0');
|
643 |
|
|
$insert_search_time_limit = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'time_limit', '$search_time_limit', '')";
|
644 |
|
|
$database->query($insert_search_time_limit);
|
645 |
|
|
// some config-elements
|
646 |
|
|
$database->query("INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'cfg_enable_old_search', 'true', '')");
|
647 |
|
|
$database->query("INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'cfg_search_keywords', 'true', '')");
|
648 |
|
|
$database->query("INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'cfg_search_description', 'true', '')");
|
649 |
|
|
$database->query("INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'cfg_show_description', 'true', '')");
|
650 |
|
|
$database->query("INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'cfg_enable_flush', 'false', '')");
|
651 |
|
|
// Search template
|
652 |
|
|
$database->query("INSERT INTO `".TABLE_PREFIX."search` (name) VALUES ('template')");
|
653 |
|
|
|
654 |
|
|
require_once(WB_PATH.'/framework/initialize.php');
|
655 |
|
|
|
656 |
|
|
// Include the PclZip class file (thanks to
|
657 |
|
|
require_once(WB_PATH.'/include/pclzip/pclzip.lib.php');
|
658 |
1529
|
Luisehahne
|
|
659 |
1470
|
Luisehahne
|
// Install add-ons
|
660 |
|
|
if(file_exists(WB_PATH.'/install/modules')) {
|
661 |
|
|
// Unpack pre-packaged modules
|
662 |
|
|
|
663 |
|
|
}
|
664 |
|
|
if(file_exists(WB_PATH.'/install/templates')) {
|
665 |
|
|
// Unpack pre-packaged templates
|
666 |
|
|
|
667 |
|
|
}
|
668 |
|
|
if(file_exists(WB_PATH.'/install/languages')) {
|
669 |
|
|
// Unpack pre-packaged languages
|
670 |
|
|
|
671 |
|
|
}
|
672 |
1529
|
Luisehahne
|
|
673 |
|
|
$admin=new admin_dummy('Start','',false,false);
|
674 |
|
|
|
675 |
1470
|
Luisehahne
|
// Load addons into DB
|
676 |
|
|
$dirs['modules'] = WB_PATH.'/modules/';
|
677 |
|
|
$dirs['templates'] = WB_PATH.'/templates/';
|
678 |
|
|
$dirs['languages'] = WB_PATH.'/languages/';
|
679 |
1540
|
Luisehahne
|
|
680 |
1470
|
Luisehahne
|
foreach($dirs AS $type => $dir) {
|
681 |
|
|
if($handle = opendir($dir)) {
|
682 |
|
|
while(false !== ($file = readdir($handle))) {
|
683 |
|
|
if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'admin.php' AND $file != 'index.php') {
|
684 |
|
|
// Get addon type
|
685 |
|
|
if($type == 'modules') {
|
686 |
|
|
load_module($dir.'/'.$file, true);
|
687 |
|
|
// Pretty ugly hack to let modules run $admin->set_error
|
688 |
|
|
// See dummy class definition admin_dummy above
|
689 |
|
|
if ($admin->error!='') {
|
690 |
|
|
set_error($admin->error);
|
691 |
|
|
}
|
692 |
|
|
} elseif($type == 'templates') {
|
693 |
|
|
load_template($dir.'/'.$file);
|
694 |
|
|
} elseif($type == 'languages') {
|
695 |
|
|
load_language($dir.'/'.$file);
|
696 |
|
|
}
|
697 |
|
|
}
|
698 |
|
|
}
|
699 |
|
|
closedir($handle);
|
700 |
|
|
}
|
701 |
|
|
}
|
702 |
|
|
|
703 |
|
|
// Check if there was a database error
|
704 |
|
|
if($database->is_error()) {
|
705 |
|
|
set_error($database->get_error());
|
706 |
|
|
}
|
707 |
|
|
|
708 |
|
|
// end of if install_tables
|
709 |
|
|
} else {
|
710 |
|
|
/**
|
711 |
|
|
* DB - Exists
|
712 |
|
|
* Tables also?
|
713 |
|
|
*
|
714 |
|
|
*/
|
715 |
|
|
$requested_tables = array("pages","sections","settings","users","groups","search","addons");
|
716 |
|
|
for($i=0;$i<count($requested_tables);$i++) $requested_tables[$i] = $table_prefix.$requested_tables[$i];
|
717 |
|
|
|
718 |
|
|
$result = mysql_list_tables( DB_NAME );
|
719 |
|
|
$all_tables = array();
|
720 |
|
|
for($i=0; $i < mysql_num_rows($result); $i++) $all_tables[] = mysql_table_name($result, $i);
|
721 |
|
|
|
722 |
|
|
$missing_tables = array();
|
723 |
|
|
foreach($requested_tables as $temp_table) {
|
724 |
|
|
if (!in_array($temp_table, $all_tables)) {
|
725 |
|
|
$missing_tables[] = $temp_table;
|
726 |
|
|
}
|
727 |
|
|
}
|
728 |
|
|
|
729 |
|
|
/**
|
730 |
|
|
* If one or more needed tables are missing, so
|
731 |
|
|
* we can't go on and have to display an error
|
732 |
|
|
*/
|
733 |
|
|
if ( count($missing_tables) > 0 ) {
|
734 |
|
|
$error_message = "One or more tables are missing in the selected database <b><font color='#990000'>".DB_NAME."</font></b>.<br />";
|
735 |
|
|
$error_message .= "Please install the missing tables or choose 'install tables' as recommend.<br />";
|
736 |
|
|
$error_message .= "Missing tables are: <b>".implode(", ", $missing_tables)."</b>";
|
737 |
|
|
|
738 |
|
|
set_error( $error_message );
|
739 |
|
|
}
|
740 |
|
|
|
741 |
|
|
/**
|
742 |
|
|
* Try to get some default settings ...
|
743 |
|
|
*/
|
744 |
|
|
$vars = array(
|
745 |
|
|
'DEFAULT_THEME' => "wb_theme",
|
746 |
|
|
'THEME_URL' => WB_URL."/templates/wb_theme",
|
747 |
|
|
'THEME_PATH' => WB_PATH."/templates/wb_theme",
|
748 |
|
|
'LANGUAGE' => $_POST['default_language'],
|
749 |
|
|
'SERVER_EMAIL' => "admin@yourdomain.com",
|
750 |
|
|
'SMART_LOGIN' => false
|
751 |
|
|
);
|
752 |
|
|
foreach($vars as $k => $v) if (!defined($k)) define($k, $v);
|
753 |
|
|
|
754 |
|
|
if (!isset($MESSAGE)) include (WB_PATH."/languages/".LANGUAGE.".php");
|
755 |
|
|
|
756 |
|
|
/**
|
757 |
|
|
* The important part ...
|
758 |
|
|
* Is there an valid user?
|
759 |
|
|
*/
|
760 |
|
|
$result = $database->query("SELECT * from ".$table_prefix."users where username='".$_POST['admin_username']."'");
|
761 |
|
|
if ( $database->is_error() ) {
|
762 |
|
|
set_error ($database->get_error() );
|
763 |
|
|
}
|
764 |
|
|
if ($result->numRows() == 0) {
|
765 |
|
|
/**
|
766 |
|
|
* No matches found ... user properly unknown
|
767 |
|
|
*/
|
768 |
|
|
set_error ("Unkown user. Please use a valid username.");
|
769 |
|
|
} else {
|
770 |
|
|
|
771 |
|
|
$data = $result->fetchRow();
|
772 |
|
|
/**
|
773 |
|
|
* Does the password match
|
774 |
|
|
*/
|
775 |
|
|
if ( md5($_POST['admin_password']) != $data['password']) {
|
776 |
|
|
set_error ("Password didn't match");
|
777 |
|
|
}
|
778 |
|
|
}
|
779 |
|
|
}
|
780 |
1529
|
Luisehahne
|
|
781 |
|
|
$ThemeUrl = WB_URL.$admin->correct_theme_source('warning.html');
|
782 |
|
|
// Setup template object, parse vars to it, then parse it
|
783 |
|
|
$ThemePath = realpath(WB_PATH.$admin->correct_theme_source('login.htt'));
|
784 |
|
|
|
785 |
1470
|
Luisehahne
|
// Log the user in and go to Website Baker Administration
|
786 |
|
|
$thisApp = new Login(
|
787 |
|
|
array(
|
788 |
|
|
"MAX_ATTEMPS" => "50",
|
789 |
1529
|
Luisehahne
|
"WARNING_URL" => $ThemeUrl."/warning.html",
|
790 |
1470
|
Luisehahne
|
"USERNAME_FIELDNAME" => 'admin_username',
|
791 |
|
|
"PASSWORD_FIELDNAME" => 'admin_password',
|
792 |
|
|
"REMEMBER_ME_OPTION" => SMART_LOGIN,
|
793 |
|
|
"MIN_USERNAME_LEN" => "2",
|
794 |
1529
|
Luisehahne
|
"MIN_PASSWORD_LEN" => "3",
|
795 |
1470
|
Luisehahne
|
"MAX_USERNAME_LEN" => "30",
|
796 |
|
|
"MAX_PASSWORD_LEN" => "30",
|
797 |
|
|
'LOGIN_URL' => ADMIN_URL."/login/index.php",
|
798 |
|
|
'DEFAULT_URL' => ADMIN_URL."/start/index.php",
|
799 |
1529
|
Luisehahne
|
'TEMPLATE_DIR' => $ThemePath,
|
800 |
|
|
'TEMPLATE_FILE' => 'login.htt',
|
801 |
1470
|
Luisehahne
|
'FRONTEND' => false,
|
802 |
|
|
'FORGOTTEN_DETAILS_APP' => ADMIN_URL."/login/forgot/index.php",
|
803 |
|
|
'USERS_TABLE' => TABLE_PREFIX."users",
|
804 |
|
|
'GROUPS_TABLE' => TABLE_PREFIX."groups",
|
805 |
|
|
)
|
806 |
|
|
);
|