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