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