Revision 5
Added by stefan about 19 years ago
save.php | ||
---|---|---|
1 | 1 |
<?php |
2 | 2 |
|
3 |
// $Id: save.php,v 1.15 2005/04/25 11:53:12 rdjurovich Exp $ +// $Id: save.php,v 1.15 2005/04/25 11:53:12 rdjurovich Exp $ |
|
4 | 3 |
|
5 | 4 |
/* |
6 | 5 |
|
... | ... | |
21 | 21 |
along with Website Baker; if not, write to the Free Software |
22 | 22 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
23 | 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 |
} |
|
24 |
*/ |
|
32 | 25 |
|
33 |
// Function to set error |
|
34 |
function set_error($message) { |
|
35 |
global $_POST; |
|
36 |
if(isset($message) AND $message != '') { |
|
37 |
// Copy values entered into session so user doesn't have to re-enter everything |
|
38 |
if(isset($_POST['website_title'])) { |
|
39 |
$_SESSION['wb_url'] = $_POST['wb_url']; |
|
40 |
$_SESSION['wb_path'] = $_POST['wb_path']; |
|
41 |
$_SESSION['default_timezone'] = $_POST['default_timezone']; |
|
42 |
if(!isset($_POST['operating_system'])) { |
|
43 |
$_SESSION['operating_system'] = 'linux'; |
|
44 |
} else { |
|
45 |
$_SESSION['operating_system'] = $_POST['operating_system']; |
|
46 |
} |
|
47 |
if(!isset($_POST['world_writeable'])) { |
|
48 |
$_SESSION['world_writeable'] = false; |
|
49 |
} else { |
|
50 |
$_SESSION['world_writeable'] = true; |
|
51 |
} |
|
52 |
$_SESSION['database_host'] = $_POST['database_host']; |
|
53 |
$_SESSION['database_username'] = $_POST['database_username']; |
|
54 |
$_SESSION['database_password'] = $_POST['database_password']; |
|
55 |
$_SESSION['database_name'] = $_POST['database_name']; |
|
56 |
$_SESSION['table_prefix'] = $_POST['table_prefix']; |
|
57 |
if(!isset($_POST['install_tables'])) { |
|
58 |
$_SESSION['install_tables'] = false; |
|
59 |
} else { |
|
60 |
$_SESSION['install_tables'] = true; |
|
61 |
} |
|
62 |
$_SESSION['website_title'] = $_POST['website_title']; |
|
63 |
$_SESSION['admin_username'] = $_POST['admin_username']; |
|
64 |
$_SESSION['admin_email'] = $_POST['admin_email']; |
|
65 |
$_SESSION['admin_password'] = $_POST['admin_password']; |
|
66 |
} |
|
67 |
// Set the message |
|
68 |
$_SESSION['message'] = $message; |
|
69 |
// Specify that session support is enabled |
|
70 |
$_SESSION['session_support'] = '<font class="good">Enabled</font>'; |
|
71 |
// Redirect to first page again and exit |
|
72 |
header('Location: index.php?sessions_checked=true'); |
|
73 |
exit(); |
|
74 |
} |
|
75 |
} |
|
26 |
// Start a session |
|
27 |
if(!defined('SESSION_STARTED')) { |
|
28 |
session_name('wb_session_id'); |
|
29 |
session_start(); |
|
30 |
define('SESSION_STARTED', true); |
|
31 |
} |
|
76 | 32 |
|
77 |
// Function to workout what the default permissions are for files created by the webserver |
|
78 |
function default_file_mode($temp_dir) { |
|
33 |
// Function to set error |
|
34 |
function set_error($message) { |
|
35 |
global $_POST; |
|
36 |
if(isset($message) AND $message != '') { |
|
37 |
// Copy values entered into session so user doesn't have to re-enter everything |
|
38 |
if(isset($_POST['website_title'])) { |
|
39 |
$_SESSION['wb_url'] = $_POST['wb_url']; |
|
40 |
$_SESSION['wb_path'] = $_POST['wb_path']; |
|
41 |
$_SESSION['default_timezone'] = $_POST['default_timezone']; |
|
42 |
if(!isset($_POST['operating_system'])) { |
|
43 |
$_SESSION['operating_system'] = 'linux'; |
|
44 |
} else { |
|
45 |
$_SESSION['operating_system'] = $_POST['operating_system']; |
|
46 |
} |
|
47 |
if(!isset($_POST['world_writeable'])) { |
|
48 |
$_SESSION['world_writeable'] = false; |
|
49 |
} else { |
|
50 |
$_SESSION['world_writeable'] = true; |
|
51 |
} |
|
52 |
$_SESSION['database_host'] = $_POST['database_host']; |
|
53 |
$_SESSION['database_username'] = $_POST['database_username']; |
|
54 |
$_SESSION['database_password'] = $_POST['database_password']; |
|
55 |
$_SESSION['database_name'] = $_POST['database_name']; |
|
56 |
$_SESSION['table_prefix'] = $_POST['table_prefix']; |
|
57 |
if(!isset($_POST['install_tables'])) { |
|
58 |
$_SESSION['install_tables'] = false; |
|
59 |
} else { |
|
60 |
$_SESSION['install_tables'] = true; |
|
61 |
} |
|
62 |
$_SESSION['website_title'] = $_POST['website_title']; |
|
63 |
$_SESSION['admin_username'] = $_POST['admin_username']; |
|
64 |
$_SESSION['admin_email'] = $_POST['admin_email']; |
|
65 |
$_SESSION['admin_password'] = $_POST['admin_password']; |
|
66 |
} |
|
67 |
// Set the message |
|
68 |
$_SESSION['message'] = $message; |
|
69 |
// Specify that session support is enabled |
|
70 |
$_SESSION['session_support'] = '<font class="good">Enabled</font>'; |
|
71 |
// Redirect to first page again and exit |
|
72 |
header('Location: index.php?sessions_checked=true'); |
|
73 |
exit(); |
|
74 |
} |
|
75 |
} |
|
76 |
|
|
77 |
// Function to workout what the default permissions are for files created by the webserver |
|
78 |
function default_file_mode($temp_dir) { |
|
79 | 79 |
$v = explode(".",PHP_VERSION); |
80 | 80 |
$v = $v[0].$v[1]; |
81 |
if($v > 41 AND is_writable($temp_dir)) { |
|
81 |
if($v > 41 AND is_writable($temp_dir)) {
|
|
82 | 82 |
$filename = $temp_dir.'/test_permissions.txt'; |
83 | 83 |
$handle = fopen($filename, 'w'); |
84 | 84 |
fwrite($handle, 'This file is to get the default file permissions'); |
... | ... | |
91 | 91 |
return $default_file_mode; |
92 | 92 |
} |
93 | 93 |
|
94 |
// Function to workout what the default permissions are for directories created by the webserver |
|
94 |
// Function to workout what the default permissions are for directories created by the webserver
|
|
95 | 95 |
function default_dir_mode($temp_dir) { |
96 | 96 |
$v = explode(".",PHP_VERSION); |
97 | 97 |
$v = $v[0].$v[1]; |
... | ... | |
104 | 104 |
$default_dir_mode = '0777'; |
105 | 105 |
} |
106 | 106 |
return $default_dir_mode; |
107 |
} |
|
108 |
|
|
109 |
// Begin check to see if form was even submitted |
|
110 |
// Set error if no post vars found |
|
111 |
if(!isset($_POST['website_title'])) { |
|
112 |
set_error('Please fill-in the form below'); |
|
113 |
} |
|
107 |
}
|
|
108 |
|
|
109 |
// Begin check to see if form was even submitted
|
|
110 |
// Set error if no post vars found
|
|
111 |
if(!isset($_POST['website_title'])) {
|
|
112 |
set_error('Please fill-in the form below');
|
|
113 |
}
|
|
114 | 114 |
// End check to see if form was even submitted |
115 |
|
|
115 |
|
|
116 | 116 |
// Begin path and timezone details code |
117 |
// Check if user has entered the installation path |
|
118 |
if(!isset($_POST['wb_path']) OR $_POST['wb_path'] == '') { |
|
119 |
set_error('Please enter an absolute path'); |
|
120 |
} else { |
|
121 |
$wb_path = $_POST['wb_path']; |
|
122 |
} |
|
123 |
// Check if user has entered the installation url |
|
124 |
if(!isset($_POST['wb_url']) OR $_POST['wb_url'] == '') { |
|
125 |
set_error('Please enter an absolute URL'); |
|
126 |
} else { |
|
127 |
$wb_url = $_POST['wb_url']; |
|
128 |
} |
|
129 |
// Remove any slashes at the end of the URL and path |
|
117 |
// Check if user has entered the installation path
|
|
118 |
if(!isset($_POST['wb_path']) OR $_POST['wb_path'] == '') {
|
|
119 |
set_error('Please enter an absolute path');
|
|
120 |
} else {
|
|
121 |
$wb_path = $_POST['wb_path'];
|
|
122 |
}
|
|
123 |
// Check if user has entered the installation url
|
|
124 |
if(!isset($_POST['wb_url']) OR $_POST['wb_url'] == '') {
|
|
125 |
set_error('Please enter an absolute URL');
|
|
126 |
} else {
|
|
127 |
$wb_url = $_POST['wb_url'];
|
|
128 |
}
|
|
129 |
// Remove any slashes at the end of the URL and path
|
|
130 | 130 |
if(substr($wb_url, strlen($wb_url)-1, 1) == "/") { |
131 | 131 |
$wb_url = substr($wb_url, 0, strlen($wb_url)-1); |
132 | 132 |
} |
133 | 133 |
if(substr($wb_path, strlen($wb_path)-1, 1) == "/") { |
134 | 134 |
$wb_path = substr($wb_path, 0, strlen($wb_path)-1); |
135 |
} |
|
135 |
}
|
|
136 | 136 |
if(substr($wb_url, strlen($wb_url)-1, 1) == "\\") { |
137 | 137 |
$wb_url = substr($wb_url, 0, strlen($wb_url)-1); |
138 | 138 |
} |
139 | 139 |
if(substr($wb_path, strlen($wb_path)-1, 1) == "\\") { |
140 | 140 |
$wb_path = substr($wb_path, 0, strlen($wb_path)-1); |
141 |
} |
|
141 |
}
|
|
142 | 142 |
if(substr($wb_url, strlen($wb_url)-1, 1) == "/") { |
143 | 143 |
$wb_url = substr($wb_url, 0, strlen($wb_url)-1); |
144 | 144 |
} |
145 | 145 |
if(substr($wb_path, strlen($wb_path)-1, 1) == "/") { |
146 | 146 |
$wb_path = substr($wb_path, 0, strlen($wb_path)-1); |
147 |
} |
|
147 |
}
|
|
148 | 148 |
if(substr($wb_url, strlen($wb_url)-1, 1) == "\\") { |
149 | 149 |
$wb_url = substr($wb_url, 0, strlen($wb_url)-1); |
150 | 150 |
} |
151 | 151 |
if(substr($wb_path, strlen($wb_path)-1, 1) == "\\") { |
152 | 152 |
$wb_path = substr($wb_path, 0, strlen($wb_path)-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'); |
|
157 |
} else { |
|
158 |
$default_timezone = $_POST['default_timezone']*60*60; |
|
159 |
} |
|
160 |
// End path and timezone details code |
|
161 |
|
|
162 |
// Begin operating system specific code |
|
163 |
// Get operating system |
|
164 |
if(!isset($_POST['operating_system']) OR $_POST['operating_system'] != 'linux' AND $_POST['operating_system'] != 'windows') { |
|
165 |
set_error('Please select a valid operating system'); |
|
166 |
} else { |
|
167 |
$operating_system = $_POST['operating_system']; |
|
168 |
} |
|
169 |
// Work-out file permissions |
|
170 |
if($operating_system == 'windows') { |
|
171 |
$file_mode = '0777'; |
|
172 |
$dir_mode = '0777'; |
|
173 |
} elseif(isset($_POST['world_writeable']) AND $_POST['world_writeable'] == 'true') { |
|
174 |
$file_mode = '0777'; |
|
175 |
$dir_mode = '0777'; |
|
176 |
} else { |
|
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');
|
|
157 |
} else {
|
|
158 |
$default_timezone = $_POST['default_timezone']*60*60;
|
|
159 |
}
|
|
160 |
// End path and timezone details code
|
|
161 |
|
|
162 |
// Begin operating system specific code
|
|
163 |
// Get operating system
|
|
164 |
if(!isset($_POST['operating_system']) OR $_POST['operating_system'] != 'linux' AND $_POST['operating_system'] != 'windows') {
|
|
165 |
set_error('Please select a valid operating system');
|
|
166 |
} else {
|
|
167 |
$operating_system = $_POST['operating_system'];
|
|
168 |
}
|
|
169 |
// Work-out file permissions
|
|
170 |
if($operating_system == 'windows') {
|
|
171 |
$file_mode = '0777';
|
|
172 |
$dir_mode = '0777';
|
|
173 |
} elseif(isset($_POST['world_writeable']) AND $_POST['world_writeable'] == 'true') {
|
|
174 |
$file_mode = '0777';
|
|
175 |
$dir_mode = '0777';
|
|
176 |
} else {
|
|
177 | 177 |
$file_mode = default_file_mode('../temp'); |
178 |
$dir_mode = default_dir_mode('../temp'); |
|
179 |
} |
|
180 |
// End operating system specific code |
|
181 |
|
|
178 |
$dir_mode = default_dir_mode('../temp');
|
|
179 |
}
|
|
180 |
// End operating system specific code
|
|
181 |
|
|
182 | 182 |
// Begin database details code |
183 | 183 |
// Check if user has entered a database host |
184 | 184 |
if(!isset($_POST['database_host']) OR $_POST['database_host'] == '') { |
... | ... | |
205 | 205 |
$database_name = $_POST['database_name']; |
206 | 206 |
} |
207 | 207 |
// Get table prefix |
208 |
$table_prefix = $_POST['table_prefix']; |
|
209 |
// Find out if the user wants to install tables and data |
|
210 |
if(isset($_POST['install_tables']) AND $_POST['install_tables'] == 'true') { |
|
211 |
$install_tables = true; |
|
212 |
} else { |
|
213 |
$install_tables = false; |
|
208 |
$table_prefix = $_POST['table_prefix'];
|
|
209 |
// Find out if the user wants to install tables and data
|
|
210 |
if(isset($_POST['install_tables']) AND $_POST['install_tables'] == 'true') {
|
|
211 |
$install_tables = true;
|
|
212 |
} else {
|
|
213 |
$install_tables = false;
|
|
214 | 214 |
} |
215 | 215 |
// End database details code |
216 |
|
|
217 |
// Begin website title code |
|
218 |
// Get website title |
|
219 |
if(!isset($_POST['website_title']) OR $_POST['website_title'] == '') { |
|
220 |
set_error('Please enter a website title'); |
|
221 |
} else { |
|
222 |
$website_title = addslashes($_POST['website_title']); |
|
223 |
} |
|
224 |
// End website title code |
|
225 |
|
|
226 |
// Begin admin user details code |
|
227 |
// Get admin username |
|
228 |
if(!isset($_POST['admin_username']) OR $_POST['admin_username'] == '') { |
|
229 |
set_error('Please enter a username for the Administrator account'); |
|
230 |
} else { |
|
231 |
$admin_username = $_POST['admin_username']; |
|
232 |
} |
|
233 |
// Get admin email and validate it |
|
234 |
if(!isset($_POST['admin_email']) OR $_POST['admin_email'] == '') { |
|
235 |
set_error('Please enter an email for the Administrator account'); |
|
236 |
} else { |
|
237 |
if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $_POST['admin_email'])) { |
|
238 |
$admin_email = $_POST['admin_email']; |
|
239 |
} else { |
|
240 |
set_error('Please enter a valid email address for the Administrator account'); |
|
241 |
} |
|
242 |
} |
|
243 |
// Get the two admin passwords entered, and check that they match |
|
244 |
if(!isset($_POST['admin_password']) OR $_POST['admin_password'] == '') { |
|
245 |
set_error('Please enter a password for the Administrator account'); |
|
246 |
} else { |
|
247 |
$admin_password = $_POST['admin_password']; |
|
248 |
} |
|
249 |
if(!isset($_POST['admin_repassword']) OR $_POST['admin_repassword'] == '') { |
|
250 |
set_error('Please make sure you re-enter the password for the Administrator account'); |
|
251 |
} else { |
|
252 |
$admin_repassword = $_POST['admin_repassword']; |
|
253 |
} |
|
254 |
if($admin_password != $admin_repassword) { |
|
255 |
set_error('Sorry, the two Administrator account passwords you entered do not match'); |
|
256 |
} |
|
257 |
// End admin user details code |
|
258 |
|
|
216 |
|
|
217 |
// Begin website title code
|
|
218 |
// Get website title
|
|
219 |
if(!isset($_POST['website_title']) OR $_POST['website_title'] == '') {
|
|
220 |
set_error('Please enter a website title');
|
|
221 |
} else {
|
|
222 |
$website_title = addslashes($_POST['website_title']);
|
|
223 |
}
|
|
224 |
// End website title code
|
|
225 |
|
|
226 |
// Begin admin user details code
|
|
227 |
// Get admin username
|
|
228 |
if(!isset($_POST['admin_username']) OR $_POST['admin_username'] == '') {
|
|
229 |
set_error('Please enter a username for the Administrator account');
|
|
230 |
} else {
|
|
231 |
$admin_username = $_POST['admin_username'];
|
|
232 |
}
|
|
233 |
// Get admin email and validate it
|
|
234 |
if(!isset($_POST['admin_email']) OR $_POST['admin_email'] == '') {
|
|
235 |
set_error('Please enter an email for the Administrator account');
|
|
236 |
} else {
|
|
237 |
if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $_POST['admin_email'])) {
|
|
238 |
$admin_email = $_POST['admin_email'];
|
|
239 |
} else {
|
|
240 |
set_error('Please enter a valid email address for the Administrator account');
|
|
241 |
}
|
|
242 |
}
|
|
243 |
// Get the two admin passwords entered, and check that they match
|
|
244 |
if(!isset($_POST['admin_password']) OR $_POST['admin_password'] == '') {
|
|
245 |
set_error('Please enter a password for the Administrator account');
|
|
246 |
} else {
|
|
247 |
$admin_password = $_POST['admin_password'];
|
|
248 |
}
|
|
249 |
if(!isset($_POST['admin_repassword']) OR $_POST['admin_repassword'] == '') {
|
|
250 |
set_error('Please make sure you re-enter the password for the Administrator account');
|
|
251 |
} else {
|
|
252 |
$admin_repassword = $_POST['admin_repassword'];
|
|
253 |
}
|
|
254 |
if($admin_password != $admin_repassword) {
|
|
255 |
set_error('Sorry, the two Administrator account passwords you entered do not match');
|
|
256 |
}
|
|
257 |
// End admin user details code
|
|
258 |
|
|
259 | 259 |
// Try and write settings to config file |
260 | 260 |
$config_content = "" . |
261 | 261 |
"<?php\n". |
... | ... | |
277 | 277 |
"define('DEFAULT_TIMEZONE', '$default_timezone');\n". |
278 | 278 |
"define('DEFAULT_DATE_FORMAT', 'M d Y');\n". |
279 | 279 |
"define('DEFAULT_TIME_FORMAT', 'g:i A');\n". |
280 |
"\n". |
|
281 |
"define('HOME_FOLDERS', true);\n". |
|
282 | 280 |
"\n". |
283 |
"define('DEFAULT_TEMPLATE', 'round');\n". |
|
284 |
"define('MULTIPLE_MENUS', false);\n". |
|
285 |
"\n". |
|
286 |
"define('PAGE_LEVEL_LIMIT', '4');\n". |
|
287 |
"define('INTRO_PAGE', false);\n". |
|
288 |
"define('PAGE_TRASH', 'disabled');\n". |
|
289 |
"define('HOMEPAGE_REDIRECTION', false);\n". |
|
281 |
"define('HOME_FOLDERS', true);\n". |
|
282 |
"\n". |
|
283 |
"define('DEFAULT_TEMPLATE', 'round');\n". |
|
284 |
"define('MULTIPLE_MENUS', false);\n". |
|
285 |
"\n". |
|
286 |
"define('PAGE_LEVEL_LIMIT', '4');\n". |
|
287 |
"define('INTRO_PAGE', false);\n". |
|
288 |
"define('PAGE_TRASH', 'disabled');\n". |
|
289 |
"define('HOMEPAGE_REDIRECTION', false);\n". |
|
290 | 290 |
"define('PAGE_LANGUAGES', false);\n". |
291 |
"\n". |
|
292 |
"define('WYSIWYG_STYLE', 'font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px;');\n". |
|
293 | 291 |
"\n". |
294 |
"define('MANAGE_SECTIONS', true);\n". |
|
295 |
"define('SECTION_BLOCKS', false);\n". |
|
292 |
"define('WYSIWYG_STYLE', 'font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px;');\n". |
|
296 | 293 |
"\n". |
294 |
"define('MANAGE_SECTIONS', true);\n". |
|
295 |
"define('SECTION_BLOCKS', false);\n". |
|
296 |
"\n". |
|
297 | 297 |
"define('SMART_LOGIN', false);\n". |
298 | 298 |
"define('FRONTEND_LOGIN', false);\n". |
299 | 299 |
"define('FRONTEND_SIGNUP', '');\n". |
300 | 300 |
"\n". |
301 |
"define('SERVER_EMAIL', '".$admin_email."');\n". |
|
301 |
"define('SERVER_EMAIL', '".$admin_email."');\n".
|
|
302 | 302 |
"\n". |
303 | 303 |
"define('SEARCH', 'public');\n". |
304 | 304 |
"\n". |
... | ... | |
307 | 307 |
"\n". |
308 | 308 |
"define('PAGES_DIRECTORY', '/pages');\n". |
309 | 309 |
"define('MEDIA_DIRECTORY', '/media');\n". |
310 |
"\n". |
|
310 |
"\n".
|
|
311 | 311 |
"define('OPERATING_SYSTEM', '$operating_system');\n". |
312 | 312 |
"define('OCTAL_FILE_MODE', $file_mode);\n". |
313 | 313 |
"define('STRING_FILE_MODE', '$file_mode');\n". |
... | ... | |
337 | 337 |
} |
338 | 338 |
} else { |
339 | 339 |
set_error("The configuration file $config_filename is not writable. Change its permissions so it is, then re-run step 4."); |
340 |
} |
|
340 |
}
|
|
341 | 341 |
|
342 | 342 |
// Include configuration file |
343 |
require('../config.php'); |
|
344 |
|
|
345 |
// Check if the user has entered a correct path |
|
346 |
if(!file_exists(WB_PATH.'/framework/class.admin.php')) { |
|
347 |
set_error('It appears the Absolute path that you entered is incorrect'); |
|
348 |
} |
|
349 |
|
|
350 |
// Include WB functions file |
|
351 |
if(!defined('FUNCTIONS_FILE_LOADED')) { |
|
352 |
require(WB_PATH.'/framework/functions.php'); |
|
353 |
} |
|
343 |
require('../config.php'); |
|
354 | 344 |
|
345 |
// Check if the user has entered a correct path |
|
346 |
if(!file_exists(WB_PATH.'/framework/class.admin.php')) { |
|
347 |
set_error('It appears the Absolute path that you entered is incorrect'); |
|
348 |
} |
|
349 |
|
|
350 |
// Include WB functions file |
|
351 |
require_once(WB_PATH.'/framework/functions.php'); |
|
352 |
|
|
355 | 353 |
// Try connecting to database |
356 |
if(!mysql_connect(DB_HOST, DB_USERNAME, DB_PASSWORD)) { |
|
357 |
set_error('Database host name, username and/or password incorrect. MySQL Error:<br />'.mysql_error()); |
|
358 |
} |
|
359 |
|
|
354 |
if(!mysql_connect(DB_HOST, DB_USERNAME, DB_PASSWORD)) {
|
|
355 |
set_error('Database host name, username and/or password incorrect. MySQL Error:<br />'.mysql_error());
|
|
356 |
}
|
|
357 |
|
|
360 | 358 |
// Try to create the database |
361 |
mysql_query('CREATE DATABASE '.$database_name); |
|
362 |
|
|
363 |
// Close the mysql connection |
|
364 |
mysql_close(); |
|
365 |
|
|
366 |
// Re-connect to the database, this time using in-build database class |
|
367 |
require(WB_PATH.'/framework/class.admin.php'); |
|
359 |
mysql_query('CREATE DATABASE '.$database_name);
|
|
360 |
|
|
361 |
// Close the mysql connection
|
|
362 |
mysql_close();
|
|
363 |
|
|
364 |
// Re-connect to the database, this time using in-build database class
|
|
365 |
require(WB_PATH.'/framework/class.admin.php');
|
|
368 | 366 |
$database = new database(); |
369 | 367 |
|
370 | 368 |
// Check if we should install tables |
... | ... | |
403 | 401 |
. ' `page_title` VARCHAR( 255 ) NOT NULL ,' |
404 | 402 |
. ' `menu_title` VARCHAR( 255 ) NOT NULL ,' |
405 | 403 |
. ' `description` TEXT NOT NULL ,' |
406 |
. ' `keywords` TEXT NOT NULL ,' |
|
404 |
. ' `keywords` TEXT NOT NULL ,'
|
|
407 | 405 |
. ' `page_trail` TEXT NOT NULL ,' |
408 | 406 |
. ' `template` VARCHAR( 255 ) NOT NULL ,' |
409 | 407 |
. ' `visibility` VARCHAR( 255 ) NOT NULL ,' |
410 |
. ' `position` INT NOT NULL ,' |
|
411 |
. ' `menu` INT NOT NULL ,' |
|
408 |
. ' `position` INT NOT NULL ,'
|
|
409 |
. ' `menu` INT NOT NULL ,'
|
|
412 | 410 |
. ' `language` VARCHAR( 5 ) NOT NULL ,' |
413 | 411 |
. ' `searching` INT NOT NULL ,' |
414 | 412 |
. ' `admin_groups` TEXT NOT NULL ,' |
... | ... | |
425 | 423 |
$pages = 'CREATE TABLE `'.TABLE_PREFIX.'sections` ( `section_id` INT NOT NULL auto_increment,' |
426 | 424 |
. ' `page_id` INT NOT NULL ,' |
427 | 425 |
. ' `position` INT NOT NULL ,' |
428 |
. ' `module` VARCHAR( 255 ) NOT NULL ,' |
|
426 |
. ' `module` VARCHAR( 255 ) NOT NULL ,'
|
|
429 | 427 |
. ' `block` VARCHAR( 255 ) NOT NULL ,' |
430 | 428 |
. ' PRIMARY KEY ( `section_id` ) )' |
431 | 429 |
. ' '; |
... | ... | |
452 | 450 |
. ' `timezone` INT NOT NULL ,' |
453 | 451 |
. ' `date_format` VARCHAR( 255 ) NOT NULL ,' |
454 | 452 |
. ' `time_format` VARCHAR( 255 ) NOT NULL ,' |
455 |
. ' `language` VARCHAR( 5 ) NOT NULL ,' |
|
453 |
. ' `language` VARCHAR( 5 ) NOT NULL ,'
|
|
456 | 454 |
. ' `home_folder` TEXT NOT NULL ,' |
457 | 455 |
. ' `login_when` INT NOT NULL ,' |
458 | 456 |
. ' `login_ip` VARCHAR( 15 ) NOT NULL ,' |
... | ... | |
535 | 533 |
$search_footer = addslashes(''); |
536 | 534 |
$insert_search_footer = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'footer', '$search_footer', '')"; |
537 | 535 |
$database->query($insert_search_footer); |
538 |
// Search results header |
|
539 |
$search_results_header = addslashes(''. |
|
540 |
'[TEXT_RESULTS_FOR] \'<b>[SEARCH_STRING]</b>\': |
|
536 |
// Search results header
|
|
537 |
$search_results_header = addslashes(''.
|
|
538 |
'[TEXT_RESULTS_FOR] \'<b>[SEARCH_STRING]</b>\':
|
|
541 | 539 |
<table cellpadding="2" cellspacing="0" border="0" width="100%" style="padding-top: 10px;">'); |
542 | 540 |
$insert_search_results_header = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'results_header', '$search_results_header', '')"; |
543 | 541 |
$database->query($insert_search_results_header); |
544 | 542 |
// Search results loop |
545 |
$search_results_loop = addslashes(''. |
|
546 |
'<tr style="background-color: #F0F0F0;"> |
|
547 |
<td><a href="[LINK]">[TITLE]</a></td> |
|
548 |
<td align="right">[TEXT_LAST_UPDATED_BY] [DISPLAY_NAME] ([USERNAME]) [TEXT_ON] [DATE]</td> |
|
549 |
</tr> |
|
543 |
$search_results_loop = addslashes(''.
|
|
544 |
'<tr style="background-color: #F0F0F0;">
|
|
545 |
<td><a href="[LINK]">[TITLE]</a></td>
|
|
546 |
<td align="right">[TEXT_LAST_UPDATED_BY] [DISPLAY_NAME] ([USERNAME]) [TEXT_ON] [DATE]</td>
|
|
547 |
</tr>
|
|
550 | 548 |
<tr><td colspan="2" style="text-align: justify; padding-bottom: 10px;">[DESCRIPTION]</td></tr>'); |
551 | 549 |
$insert_search_results_loop = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'results_loop', '$search_results_loop', '')"; |
552 | 550 |
$database->query($insert_search_results_loop); |
... | ... | |
559 | 557 |
$insert_search_no_results = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'no_results', '$search_no_results', '')"; |
560 | 558 |
$database->query($insert_search_no_results); |
561 | 559 |
// Search template |
562 |
$database->query("INSERT INTO `".TABLE_PREFIX."search` (name) VALUES ('template')"); |
|
560 |
$database->query("INSERT INTO `".TABLE_PREFIX."search` (name) VALUES ('template')");
|
|
563 | 561 |
|
564 | 562 |
// Include the pre-installed module install scripts |
565 | 563 |
require(WB_PATH.'/modules/wysiwyg/install.php'); |
... | ... | |
568 | 566 |
require(WB_PATH.'/modules/form/install.php'); |
569 | 567 |
require(WB_PATH.'/modules/wrapper/install.php'); |
570 | 568 |
|
571 |
// Check if there was a database error |
|
569 |
// Check if there was a database error
|
|
572 | 570 |
if($database->is_error()) { |
573 | 571 |
set_error($database->get_error()); |
574 |
} |
|
572 |
}
|
|
575 | 573 |
|
576 | 574 |
} |
577 | 575 |
|
578 |
// Log the user in and go to Website Baker Administration |
|
579 |
require(WB_PATH.'/framework/class.login.php'); |
|
580 |
$thisApp = new Login( |
|
581 |
array( |
|
582 |
"MAX_ATTEMPS" => "50", |
|
583 |
"WARNING_URL" => ADMIN_URL."/login/warning.html", |
|
584 |
"USERNAME_FIELDNAME" => 'admin_username', |
|
585 |
"PASSWORD_FIELDNAME" => 'admin_password', |
|
586 |
"REMEMBER_ME_OPTION" => SMART_LOGIN, |
|
587 |
"MIN_USERNAME_LEN" => "2", |
|
588 |
"MIN_PASSWORD_LEN" => "2", |
|
589 |
"MAX_USERNAME_LEN" => "30", |
|
590 |
"MAX_PASSWORD_LEN" => "30", |
|
591 |
'LOGIN_URL' => ADMIN_URL."/login/index.php", |
|
592 |
'DEFAULT_URL' => ADMIN_URL."/start/index.php", |
|
593 |
'TEMPLATE_DIR' => ADMIN_PATH."/login", |
|
594 |
'TEMPLATE_FILE' => "template.html", |
|
595 |
'FRONTEND' => false, |
|
596 |
'FORGOTTEN_DETAILS_APP' => ADMIN_URL."/login/forgot/index.php", |
|
597 |
'USERS_TABLE' => TABLE_PREFIX."users", |
|
598 |
'GROUPS_TABLE' => TABLE_PREFIX."groups", |
|
599 |
) |
|
600 |
); |
|
576 |
// Log the user in and go to Website Baker Administration
|
|
577 |
require(WB_PATH.'/framework/class.login.php');
|
|
578 |
$thisApp = new Login(
|
|
579 |
array(
|
|
580 |
"MAX_ATTEMPS" => "50",
|
|
581 |
"WARNING_URL" => ADMIN_URL."/login/warning.html",
|
|
582 |
"USERNAME_FIELDNAME" => 'admin_username',
|
|
583 |
"PASSWORD_FIELDNAME" => 'admin_password',
|
|
584 |
"REMEMBER_ME_OPTION" => SMART_LOGIN,
|
|
585 |
"MIN_USERNAME_LEN" => "2",
|
|
586 |
"MIN_PASSWORD_LEN" => "2",
|
|
587 |
"MAX_USERNAME_LEN" => "30",
|
|
588 |
"MAX_PASSWORD_LEN" => "30",
|
|
589 |
'LOGIN_URL' => ADMIN_URL."/login/index.php",
|
|
590 |
'DEFAULT_URL' => ADMIN_URL."/start/index.php",
|
|
591 |
'TEMPLATE_DIR' => ADMIN_PATH."/login",
|
|
592 |
'TEMPLATE_FILE' => "template.html",
|
|
593 |
'FRONTEND' => false,
|
|
594 |
'FORGOTTEN_DETAILS_APP' => ADMIN_URL."/login/forgot/index.php",
|
|
595 |
'USERS_TABLE' => TABLE_PREFIX."users",
|
|
596 |
'GROUPS_TABLE' => TABLE_PREFIX."groups",
|
|
597 |
)
|
|
598 |
);
|
|
601 | 599 |
|
602 |
?> |
|
600 |
?> |
Also available in: Unified diff
Restructured frontend code and fixed various bugs