1 |
4
|
ryan
|
<?php
|
2 |
|
|
|
3 |
40
|
stefan
|
// $Id$
|
4 |
4
|
ryan
|
|
5 |
|
|
/*
|
6 |
|
|
|
7 |
|
|
Website Baker Project <http://www.websitebaker.org/>
|
8 |
|
|
Copyright (C) 2004-2005, 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 |
|
|
// Find out if the user was view advanced options or not
|
27 |
|
|
if($_POST['advanced'] == 'yes' ? $advanced = '?advanced=yes' : $advanced = '');
|
28 |
|
|
|
29 |
|
|
// Print admin header
|
30 |
|
|
require('../../config.php');
|
31 |
|
|
require_once(WB_PATH.'/framework/class.admin.php');
|
32 |
|
|
if($advanced == '') {
|
33 |
|
|
$admin = new admin('Settings', 'settings_basic');
|
34 |
|
|
$_POST['database_password'] = DB_PASSWORD;
|
35 |
|
|
} else {
|
36 |
|
|
$admin = new admin('Settings', 'settings_advanced');
|
37 |
|
|
}
|
38 |
|
|
|
39 |
|
|
// Create new database object
|
40 |
|
|
$database = new database();
|
41 |
|
|
|
42 |
|
|
// Query current settings in the db, then loop through them and update the db with the new value
|
43 |
|
|
$query = "SELECT name FROM ".TABLE_PREFIX."settings";
|
44 |
|
|
$results = $database->query($query);
|
45 |
|
|
while($setting = $results->fetchRow()) {
|
46 |
|
|
$setting_name = $setting['name'];
|
47 |
|
|
$value = $admin->get_post($setting_name);
|
48 |
40
|
stefan
|
$value = $admin->add_slashes($value);
|
49 |
4
|
ryan
|
$database->query("UPDATE ".TABLE_PREFIX."settings SET value = '$value' WHERE name = '$setting_name'");
|
50 |
|
|
}
|
51 |
|
|
|
52 |
|
|
// Query current search settings in the db, then loop through them and update the db with the new value
|
53 |
|
|
$query = "SELECT name FROM ".TABLE_PREFIX."search WHERE extra = ''";
|
54 |
|
|
$results = $database->query($query);
|
55 |
|
|
while($search_setting = $results->fetchRow()) {
|
56 |
|
|
$setting_name = $search_setting['name'];
|
57 |
|
|
$post_name = 'search_'.$search_setting['name'];
|
58 |
|
|
$value = $admin->get_post($post_name);
|
59 |
40
|
stefan
|
$value = $admin->add_slashes($value);
|
60 |
4
|
ryan
|
$database->query("UPDATE ".TABLE_PREFIX."search SET value = '$value' WHERE name = '$setting_name'");
|
61 |
|
|
}
|
62 |
|
|
|
63 |
|
|
// Check if there was an error updating the db
|
64 |
|
|
if($database->is_error()) {
|
65 |
|
|
$admin->print_error($database->get_error, ADMIN_URL.'/settings/index.php'.$advanced);
|
66 |
|
|
} else {
|
67 |
|
|
// Get timezone offset
|
68 |
|
|
$timezone_offset = $_POST['timezone']*60*60;
|
69 |
|
|
// Work out what code to put in for error reporting
|
70 |
|
|
if($_POST['er_level'] == '') {
|
71 |
|
|
$er_level = '';
|
72 |
|
|
$er_level_code = '';
|
73 |
|
|
} else {
|
74 |
|
|
$er_level = $_POST['er_level'];
|
75 |
|
|
$er_level_code = "error_reporting('".$_POST['er_level']."');\n";
|
76 |
|
|
}
|
77 |
|
|
// Work-out database type, and whether or not to use PEAR
|
78 |
|
|
$database_type = $admin->get_post('database_type');
|
79 |
|
|
|
80 |
|
|
// Work-out file mode
|
81 |
|
|
if($advanced == '') {
|
82 |
|
|
// Check if should be set to 777 or left alone
|
83 |
|
|
if(isset($_POST['world_writeable']) AND $_POST['world_writeable'] == 'true') {
|
84 |
|
|
$file_mode = '0777';
|
85 |
|
|
$dir_mode = '0777';
|
86 |
|
|
} else {
|
87 |
|
|
$file_mode = STRING_FILE_MODE;
|
88 |
|
|
$dir_mode = STRING_DIR_MODE;
|
89 |
|
|
}
|
90 |
|
|
} else {
|
91 |
|
|
// Work-out the octal value for file mode
|
92 |
|
|
$u = 0;
|
93 |
|
|
if(isset($_POST['file_u_r']) AND $_POST['file_u_r'] == 'true') {
|
94 |
|
|
$u = $u+4;
|
95 |
|
|
}
|
96 |
|
|
if(isset($_POST['file_u_w']) AND $_POST['file_u_w'] == 'true') {
|
97 |
|
|
$u = $u+2;
|
98 |
|
|
}
|
99 |
|
|
if(isset($_POST['file_u_e']) AND $_POST['file_u_e'] == 'true') {
|
100 |
|
|
$u = $u+1;
|
101 |
|
|
}
|
102 |
|
|
$g = 0;
|
103 |
|
|
if(isset($_POST['file_g_r']) AND $_POST['file_g_r'] == 'true') {
|
104 |
|
|
$g = $g+4;
|
105 |
|
|
}
|
106 |
|
|
if(isset($_POST['file_g_w']) AND $_POST['file_g_w'] == 'true') {
|
107 |
|
|
$g = $g+2;
|
108 |
|
|
}
|
109 |
|
|
if(isset($_POST['file_g_e']) AND $_POST['file_g_e'] == 'true') {
|
110 |
|
|
$g = $g+1;
|
111 |
|
|
}
|
112 |
|
|
$o = 0;
|
113 |
|
|
if(isset($_POST['file_o_r']) AND $_POST['file_o_r'] == 'true') {
|
114 |
|
|
$o = $o+4;
|
115 |
|
|
}
|
116 |
|
|
if(isset($_POST['file_o_w']) AND $_POST['file_o_w'] == 'true') {
|
117 |
|
|
$o = $o+2;
|
118 |
|
|
}
|
119 |
|
|
if(isset($_POST['file_o_e']) AND $_POST['file_o_e'] == 'true') {
|
120 |
|
|
$o = $o+1;
|
121 |
|
|
}
|
122 |
|
|
$file_mode = "0".$u.$g.$o;
|
123 |
|
|
// Work-out the octal value for dir mode
|
124 |
|
|
$u = 0;
|
125 |
|
|
if(isset($_POST['dir_u_r']) AND $_POST['dir_u_r'] == 'true') {
|
126 |
|
|
$u = $u+4;
|
127 |
|
|
}
|
128 |
|
|
if(isset($_POST['dir_u_w']) AND $_POST['dir_u_w'] == 'true') {
|
129 |
|
|
$u = $u+2;
|
130 |
|
|
}
|
131 |
|
|
if(isset($_POST['dir_u_e']) AND $_POST['dir_u_e'] == 'true') {
|
132 |
|
|
$u = $u+1;
|
133 |
|
|
}
|
134 |
|
|
$g = 0;
|
135 |
|
|
if(isset($_POST['dir_g_r']) AND $_POST['dir_g_r'] == 'true') {
|
136 |
|
|
$g = $g+4;
|
137 |
|
|
}
|
138 |
|
|
if(isset($_POST['dir_g_w']) AND $_POST['dir_g_w'] == 'true') {
|
139 |
|
|
$g = $g+2;
|
140 |
|
|
}
|
141 |
|
|
if(isset($_POST['dir_g_e']) AND $_POST['dir_g_e'] == 'true') {
|
142 |
|
|
$g = $g+1;
|
143 |
|
|
}
|
144 |
|
|
$o = 0;
|
145 |
|
|
if(isset($_POST['dir_o_r']) AND $_POST['dir_o_r'] == 'true') {
|
146 |
|
|
$o = $o+4;
|
147 |
|
|
}
|
148 |
|
|
if(isset($_POST['dir_o_w']) AND $_POST['dir_o_w'] == 'true') {
|
149 |
|
|
$o = $o+2;
|
150 |
|
|
}
|
151 |
|
|
if(isset($_POST['dir_o_e']) AND $_POST['dir_o_e'] == 'true') {
|
152 |
|
|
$o = $o+1;
|
153 |
|
|
}
|
154 |
|
|
$dir_mode = "0".$u.$g.$o;
|
155 |
|
|
}
|
156 |
|
|
|
157 |
|
|
// Rewrite WB_PATH and ADMIN_PATH if on Windows
|
158 |
|
|
if($_POST['operating_system']=='windows') {
|
159 |
|
|
$WB_PATH = str_replace('/','\\', WB_PATH);
|
160 |
|
|
$WB_PATH = str_replace('\\','\\\\', $WB_PATH);
|
161 |
|
|
$ADMIN_PATH = str_replace('/','\\', ADMIN_PATH);
|
162 |
|
|
$ADMIN_PATH = str_replace('\\','\\\\', $ADMIN_PATH);
|
163 |
|
|
} else {
|
164 |
|
|
$WB_PATH = WB_PATH;
|
165 |
|
|
$ADMIN_PATH = ADMIN_PATH;
|
166 |
|
|
}
|
167 |
|
|
// Write the remaining settings to the config file
|
168 |
|
|
$config_filename = $WB_PATH.'/config.php';
|
169 |
|
|
$config_content = "" .
|
170 |
|
|
"<?php \n".
|
171 |
|
|
"\n".
|
172 |
|
|
"define('ER_LEVEL', '$er_level');\n".
|
173 |
|
|
$er_level_code.
|
174 |
|
|
"\n".
|
175 |
|
|
"define('DEFAULT_LANGUAGE', '".str_replace(';', '', $_POST['language'])."');\n".
|
176 |
|
|
"\n".
|
177 |
|
|
"define('APP_NAME', 'wb');\n".
|
178 |
|
|
"\n".
|
179 |
|
|
"define('DB_TYPE', '".DB_TYPE."');\n".
|
180 |
|
|
"define('DB_HOST', '".DB_HOST."');\n".
|
181 |
|
|
"define('DB_USERNAME', '".DB_USERNAME."');\n".
|
182 |
|
|
"define('DB_PASSWORD', '".DB_PASSWORD."');\n".
|
183 |
|
|
"define('DB_NAME', '".DB_NAME."');\n".
|
184 |
|
|
"\n".
|
185 |
|
|
"define('TABLE_PREFIX', '".TABLE_PREFIX."');\n".
|
186 |
|
|
"\n".
|
187 |
|
|
"define('DEFAULT_TIMEZONE', '".$timezone_offset."');\n".
|
188 |
|
|
"define('DEFAULT_DATE_FORMAT', '".str_replace(';', '', $_POST['date_format'])."');\n".
|
189 |
|
|
"define('DEFAULT_TIME_FORMAT', '".str_replace(';', '', $_POST['time_format'])."');\n".
|
190 |
|
|
"\n".
|
191 |
|
|
"define('HOME_FOLDERS', ".$_POST['home_folders'].");\n".
|
192 |
|
|
"\n".
|
193 |
|
|
"define('DEFAULT_TEMPLATE', '".$_POST['template']."');\n".
|
194 |
|
|
"define('MULTIPLE_MENUS', ".str_replace(';', '', $_POST['multiple_menus']).");\n".
|
195 |
|
|
"\n".
|
196 |
|
|
"define('INTRO_PAGE', ".str_replace(';', '', $_POST['intro_page']).");\n".
|
197 |
|
|
"define('PAGE_TRASH', '".str_replace(';', '', $_POST['page_trash'])."');\n".
|
198 |
|
|
"define('PAGE_LEVEL_LIMIT', '".str_replace(';', '', $_POST['page_level_limit'])."');\n".
|
199 |
|
|
"define('HOMEPAGE_REDIRECTION', ".str_replace(';', '', $_POST['homepage_redirection']).");\n".
|
200 |
|
|
"define('PAGE_LANGUAGES', ".str_replace(';', '', $_POST['page_languages']).");\n".
|
201 |
|
|
"\n".
|
202 |
52
|
stefan
|
"define('WYSIWYG_EDITOR', '".addslashes($_POST['wysiwyg_editor'])."');\n".
|
203 |
45
|
stefan
|
"\n".
|
204 |
4
|
ryan
|
"define('MANAGE_SECTIONS', ".str_replace(';', '', $_POST['manage_sections']).");\n".
|
205 |
|
|
"define('SECTION_BLOCKS', ".str_replace(';', '', $_POST['section_blocks']).");\n".
|
206 |
|
|
"\n".
|
207 |
|
|
"define('SMART_LOGIN', ".str_replace(';', '', $_POST['smart_login']).");\n".
|
208 |
|
|
"define('FRONTEND_LOGIN', ".str_replace(';', '', $_POST['frontend_login']).");\n".
|
209 |
|
|
"define('FRONTEND_SIGNUP', ".str_replace(';', '', $_POST['frontend_signup']).");\n".
|
210 |
|
|
"\n".
|
211 |
|
|
"define('SERVER_EMAIL', '".$_POST['server_email']."');\n".
|
212 |
|
|
"\n".
|
213 |
|
|
"define('SEARCH', '".$admin->get_post('search')."');\n".
|
214 |
|
|
"\n".
|
215 |
|
|
"define('PAGE_EXTENSION', '".str_replace(';', '', $_POST['page_extension'])."');\n".
|
216 |
|
|
"define('PAGE_SPACER', '".str_replace(';', '', $_POST['page_spacer'])."');\n".
|
217 |
|
|
"\n".
|
218 |
|
|
"define('PAGES_DIRECTORY', '".PAGES_DIRECTORY."');\n".
|
219 |
|
|
"define('MEDIA_DIRECTORY', '".MEDIA_DIRECTORY."');\n".
|
220 |
|
|
"\n".
|
221 |
|
|
"define('OPERATING_SYSTEM', '".str_replace(';', '', $_POST['operating_system'])."');\n".
|
222 |
|
|
"define('OCTAL_FILE_MODE', ".$file_mode.");\n".
|
223 |
|
|
"define('STRING_FILE_MODE', '".$file_mode."');\n".
|
224 |
|
|
"define('OCTAL_DIR_MODE', ".$dir_mode.");\n".
|
225 |
|
|
"define('STRING_DIR_MODE', '".$dir_mode."');\n".
|
226 |
|
|
"\n".
|
227 |
|
|
"define('WB_PATH', '".$WB_PATH."');\n".
|
228 |
|
|
"define('WB_URL', '".WB_URL."');\n".
|
229 |
|
|
"\n".
|
230 |
|
|
"define('ADMIN_PATH', '".$ADMIN_PATH."');\n".
|
231 |
|
|
"define('ADMIN_URL', '".ADMIN_URL."');\n".
|
232 |
|
|
"\n".
|
233 |
|
|
"?>";
|
234 |
|
|
|
235 |
|
|
// Check if file is writable first
|
236 |
|
|
if(!is_writable($config_filename)) {
|
237 |
|
|
$admin->print_error($MESSAGE['SETTINGS']['UNABLE_WRITE_CONFIG'], ADMIN_URL.'/settings/index.php'.$advanced);
|
238 |
|
|
} else {
|
239 |
|
|
// Try and open the config file
|
240 |
|
|
if (!$handle = fopen($config_filename, 'w')) {
|
241 |
|
|
$admin->print_error($MESSAGE['SETTINGS']['UNABLE_OPEN_CONFIG'], ADMIN_URL.'/settings/index.php'.$advanced);
|
242 |
|
|
} else {
|
243 |
|
|
// Try and write to the config file
|
244 |
|
|
if (fwrite($handle, $config_content) === FALSE) {
|
245 |
|
|
$admin->print_error($MESSAGE['SETTINGS']['UNABLE_WRITE_CONFIG'], ADMIN_URL.'/settings/index.php'.$advanced);
|
246 |
|
|
} else {
|
247 |
|
|
$admin->print_success($MESSAGE['SETTINGS']['SAVED'], ADMIN_URL.'/settings/index.php'.$advanced);
|
248 |
|
|
}
|
249 |
|
|
}
|
250 |
|
|
}
|
251 |
|
|
|
252 |
|
|
}
|
253 |
|
|
|
254 |
|
|
$admin->print_footer();
|
255 |
|
|
|
256 |
45
|
stefan
|
?>
|