36 |
36 |
$admin = new admin('Settings', 'settings_advanced');
|
37 |
37 |
}
|
38 |
38 |
|
|
39 |
// Work-out file mode
|
|
40 |
if($advanced == '') {
|
|
41 |
// Check if should be set to 777 or left alone
|
|
42 |
if(isset($_POST['world_writeable']) AND $_POST['world_writeable'] == 'true') {
|
|
43 |
$file_mode = '0777';
|
|
44 |
$dir_mode = '0777';
|
|
45 |
} else {
|
|
46 |
$file_mode = STRING_FILE_MODE;
|
|
47 |
$dir_mode = STRING_DIR_MODE;
|
|
48 |
}
|
|
49 |
} else {
|
|
50 |
// Work-out the octal value for file mode
|
|
51 |
$u = 0;
|
|
52 |
if(isset($_POST['file_u_r']) AND $_POST['file_u_r'] == 'true') {
|
|
53 |
$u = $u+4;
|
|
54 |
}
|
|
55 |
if(isset($_POST['file_u_w']) AND $_POST['file_u_w'] == 'true') {
|
|
56 |
$u = $u+2;
|
|
57 |
}
|
|
58 |
if(isset($_POST['file_u_e']) AND $_POST['file_u_e'] == 'true') {
|
|
59 |
$u = $u+1;
|
|
60 |
}
|
|
61 |
$g = 0;
|
|
62 |
if(isset($_POST['file_g_r']) AND $_POST['file_g_r'] == 'true') {
|
|
63 |
$g = $g+4;
|
|
64 |
}
|
|
65 |
if(isset($_POST['file_g_w']) AND $_POST['file_g_w'] == 'true') {
|
|
66 |
$g = $g+2;
|
|
67 |
}
|
|
68 |
if(isset($_POST['file_g_e']) AND $_POST['file_g_e'] == 'true') {
|
|
69 |
$g = $g+1;
|
|
70 |
}
|
|
71 |
$o = 0;
|
|
72 |
if(isset($_POST['file_o_r']) AND $_POST['file_o_r'] == 'true') {
|
|
73 |
$o = $o+4;
|
|
74 |
}
|
|
75 |
if(isset($_POST['file_o_w']) AND $_POST['file_o_w'] == 'true') {
|
|
76 |
$o = $o+2;
|
|
77 |
}
|
|
78 |
if(isset($_POST['file_o_e']) AND $_POST['file_o_e'] == 'true') {
|
|
79 |
$o = $o+1;
|
|
80 |
}
|
|
81 |
$file_mode = "0".$u.$g.$o;
|
|
82 |
// Work-out the octal value for dir mode
|
|
83 |
$u = 0;
|
|
84 |
if(isset($_POST['dir_u_r']) AND $_POST['dir_u_r'] == 'true') {
|
|
85 |
$u = $u+4;
|
|
86 |
}
|
|
87 |
if(isset($_POST['dir_u_w']) AND $_POST['dir_u_w'] == 'true') {
|
|
88 |
$u = $u+2;
|
|
89 |
}
|
|
90 |
if(isset($_POST['dir_u_e']) AND $_POST['dir_u_e'] == 'true') {
|
|
91 |
$u = $u+1;
|
|
92 |
}
|
|
93 |
$g = 0;
|
|
94 |
if(isset($_POST['dir_g_r']) AND $_POST['dir_g_r'] == 'true') {
|
|
95 |
$g = $g+4;
|
|
96 |
}
|
|
97 |
if(isset($_POST['dir_g_w']) AND $_POST['dir_g_w'] == 'true') {
|
|
98 |
$g = $g+2;
|
|
99 |
}
|
|
100 |
if(isset($_POST['dir_g_e']) AND $_POST['dir_g_e'] == 'true') {
|
|
101 |
$g = $g+1;
|
|
102 |
}
|
|
103 |
$o = 0;
|
|
104 |
if(isset($_POST['dir_o_r']) AND $_POST['dir_o_r'] == 'true') {
|
|
105 |
$o = $o+4;
|
|
106 |
}
|
|
107 |
if(isset($_POST['dir_o_w']) AND $_POST['dir_o_w'] == 'true') {
|
|
108 |
$o = $o+2;
|
|
109 |
}
|
|
110 |
if(isset($_POST['dir_o_e']) AND $_POST['dir_o_e'] == 'true') {
|
|
111 |
$o = $o+1;
|
|
112 |
}
|
|
113 |
$dir_mode = "0".$u.$g.$o;
|
|
114 |
}
|
|
115 |
|
39 |
116 |
// Create new database object
|
40 |
117 |
$database = new database();
|
41 |
118 |
|
... | ... | |
46 |
123 |
$setting_name = $setting['name'];
|
47 |
124 |
$value = $admin->get_post($setting_name);
|
48 |
125 |
$value = $admin->add_slashes($value);
|
|
126 |
switch ($setting_name) {
|
|
127 |
case 'default_timezone':
|
|
128 |
$value=$value*60*60;
|
|
129 |
break;
|
|
130 |
case 'string_dir_mode':
|
|
131 |
$value=$dir_mode;
|
|
132 |
break;
|
|
133 |
case 'string_file_mode':
|
|
134 |
$value=$file_mode;
|
|
135 |
break;
|
|
136 |
}
|
49 |
137 |
$database->query("UPDATE ".TABLE_PREFIX."settings SET value = '$value' WHERE name = '$setting_name'");
|
50 |
138 |
}
|
51 |
139 |
|
... | ... | |
63 |
151 |
// Check if there was an error updating the db
|
64 |
152 |
if($database->is_error()) {
|
65 |
153 |
$admin->print_error($database->get_error, ADMIN_URL.'/settings/index.php'.$advanced);
|
|
154 |
$admin->print_footer();
|
|
155 |
exit();
|
|
156 |
}
|
|
157 |
|
|
158 |
// Get timezone offset
|
|
159 |
$timezone_offset = $_POST['timezone']*60*60;
|
|
160 |
// Work out what code to put in for error reporting
|
|
161 |
if($_POST['er_level'] == '') {
|
|
162 |
$er_level = '';
|
|
163 |
$er_level_code = '';
|
66 |
164 |
} 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 = '';
|
|
165 |
$er_level = $_POST['er_level'];
|
|
166 |
$er_level_code = "error_reporting('".$_POST['er_level']."');\n";
|
|
167 |
}
|
|
168 |
// Work-out database type, and whether or not to use PEAR
|
|
169 |
$database_type = $admin->get_post('database_type');
|
|
170 |
|
|
171 |
// Rewrite WB_PATH and ADMIN_PATH if on Windows
|
|
172 |
if($_POST['operating_system']=='windows') {
|
|
173 |
$WB_PATH = str_replace('/','\\', WB_PATH);
|
|
174 |
$WB_PATH = str_replace('\\','\\\\', $WB_PATH);
|
|
175 |
$ADMIN_PATH = str_replace('/','\\', ADMIN_PATH);
|
|
176 |
$ADMIN_PATH = str_replace('\\','\\\\', $ADMIN_PATH);
|
|
177 |
} else {
|
|
178 |
$WB_PATH = WB_PATH;
|
|
179 |
$ADMIN_PATH = ADMIN_PATH;
|
|
180 |
}
|
|
181 |
// Write the remaining settings to the config file
|
|
182 |
$config_filename = $WB_PATH.'/config.php';
|
|
183 |
$config_content = "" .
|
|
184 |
"<?php \n".
|
|
185 |
"define('DB_TYPE', '".DB_TYPE."');\n".
|
|
186 |
"define('DB_HOST', '".DB_HOST."');\n".
|
|
187 |
"define('DB_USERNAME', '".DB_USERNAME."');\n".
|
|
188 |
"define('DB_PASSWORD', '".DB_PASSWORD."');\n".
|
|
189 |
"define('DB_NAME', '".DB_NAME."');\n".
|
|
190 |
"define('TABLE_PREFIX', '".TABLE_PREFIX."');\n".
|
|
191 |
"\n".
|
|
192 |
"define('WB_PATH', '".$WB_PATH."');\n".
|
|
193 |
"define('WB_URL', '".WB_URL."');\n".
|
|
194 |
"define('ADMIN_PATH', '".$ADMIN_PATH."');\n".
|
|
195 |
"define('ADMIN_URL', '".ADMIN_URL."');\n".
|
|
196 |
"\n".
|
|
197 |
"?>";
|
|
198 |
|
|
199 |
// Check if file is writable first
|
|
200 |
if(!is_writable($config_filename)) {
|
|
201 |
$admin->print_error($MESSAGE['SETTINGS']['UNABLE_WRITE_CONFIG'], ADMIN_URL.'/settings/index.php'.$advanced);
|
|
202 |
} else {
|
|
203 |
// Try and open the config file
|
|
204 |
if (!$handle = fopen($config_filename, 'w')) {
|
|
205 |
$admin->print_error($MESSAGE['SETTINGS']['UNABLE_OPEN_CONFIG'], ADMIN_URL.'/settings/index.php'.$advanced);
|
73 |
206 |
} 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';
|
|
207 |
// Try and write to the config file
|
|
208 |
if (fwrite($handle, $config_content) === FALSE) {
|
|
209 |
$admin->print_error($MESSAGE['SETTINGS']['UNABLE_WRITE_CONFIG'], ADMIN_URL.'/settings/index.php'.$advanced);
|
86 |
210 |
} else {
|
87 |
|
$file_mode = STRING_FILE_MODE;
|
88 |
|
$dir_mode = STRING_DIR_MODE;
|
|
211 |
$admin->print_success($MESSAGE['SETTINGS']['SAVED'], ADMIN_URL.'/settings/index.php'.$advanced);
|
89 |
212 |
}
|
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 |
213 |
}
|
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 |
|
"define('DB_TYPE', '".DB_TYPE."');\n".
|
172 |
|
"define('DB_HOST', '".DB_HOST."');\n".
|
173 |
|
"define('DB_USERNAME', '".DB_USERNAME."');\n".
|
174 |
|
"define('DB_PASSWORD', '".DB_PASSWORD."');\n".
|
175 |
|
"define('DB_NAME', '".DB_NAME."');\n".
|
176 |
|
"define('TABLE_PREFIX', '".TABLE_PREFIX."');\n".
|
177 |
|
"\n".
|
178 |
|
"define('WB_PATH', '".$WB_PATH."');\n".
|
179 |
|
"define('WB_URL', '".WB_URL."');\n".
|
180 |
|
"define('ADMIN_PATH', '".$ADMIN_PATH."');\n".
|
181 |
|
"define('ADMIN_URL', '".ADMIN_URL."');\n".
|
182 |
|
"\n".
|
183 |
|
"?>";
|
184 |
|
|
185 |
|
// Check if file is writable first
|
186 |
|
if(!is_writable($config_filename)) {
|
187 |
|
$admin->print_error($MESSAGE['SETTINGS']['UNABLE_WRITE_CONFIG'], ADMIN_URL.'/settings/index.php'.$advanced);
|
188 |
|
} else {
|
189 |
|
// Try and open the config file
|
190 |
|
if (!$handle = fopen($config_filename, 'w')) {
|
191 |
|
$admin->print_error($MESSAGE['SETTINGS']['UNABLE_OPEN_CONFIG'], ADMIN_URL.'/settings/index.php'.$advanced);
|
192 |
|
} else {
|
193 |
|
// Try and write to the config file
|
194 |
|
if (fwrite($handle, $config_content) === FALSE) {
|
195 |
|
$admin->print_error($MESSAGE['SETTINGS']['UNABLE_WRITE_CONFIG'], ADMIN_URL.'/settings/index.php'.$advanced);
|
196 |
|
} else {
|
197 |
|
$admin->print_success($MESSAGE['SETTINGS']['SAVED'], ADMIN_URL.'/settings/index.php'.$advanced);
|
198 |
|
}
|
199 |
|
}
|
200 |
|
}
|
201 |
|
|
202 |
214 |
}
|
203 |
215 |
|
204 |
216 |
$admin->print_footer();
|
Fixed problems with settings in database. Should be fully functional again.