Revision 1912
Added by Dietmar over 11 years ago
save.php | ||
---|---|---|
4 | 4 |
* @category admin |
5 | 5 |
* @package settings |
6 | 6 |
* @author WebsiteBaker Project |
7 |
* @copyright 2009-2012, WebsiteBaker Org. e.V.
|
|
8 |
* @link http://www.websitebaker2.org/
|
|
7 |
* @copyright 2009-2013, WebsiteBaker Org. e.V.
|
|
8 |
* @link http://www.websitebaker.org/
|
|
9 | 9 |
* @license http://www.gnu.org/licenses/gpl.html |
10 | 10 |
* @platform WebsiteBaker 2.8.x |
11 | 11 |
* @requirements PHP 5.2.2 and higher |
12 | 12 |
* @version $Id$ |
13 |
* @filesource $HeadURL$
|
|
13 |
* @filesource $HeadURL$
|
|
14 | 14 |
* @lastmodified $Date$ |
15 | 15 |
* |
16 | 16 |
*/ |
... | ... | |
186 | 186 |
'page_spacer', |
187 | 187 |
'page_icon_dir', |
188 | 188 |
); |
189 |
$disallow_in_fields = array( |
|
190 |
'pages_directory', |
|
191 |
'media_directory', |
|
189 |
$aPreventFromUpdate = array( |
|
190 |
'sp', |
|
191 |
'version', |
|
192 |
// 'page_extension', |
|
192 | 193 |
'wb_version' |
193 | 194 |
); |
194 | 195 |
$StripCodeFromInput = array( |
... | ... | |
207 | 208 |
); |
208 | 209 |
|
209 | 210 |
// Query current settings in the db, then loop through them and update the db with the new value |
210 |
$settings = array(); |
|
211 |
$old_settings = array(); |
|
211 |
//$settings = array();
|
|
212 |
//$old_settings = array();
|
|
212 | 213 |
// Query current settings in the db, then loop through them to get old values |
213 | 214 |
$sql = 'SELECT `name`, `value` FROM `'.TABLE_PREFIX.'settings`'; |
214 | 215 |
$sql .= 'ORDER BY `name`'; |
215 | 216 |
|
216 | 217 |
if($res_settings = $database->query($sql)) { |
217 |
$passed = false;
|
|
218 |
$iQueryStart = $database->getQueryCount;
|
|
218 | 219 |
while($setting = $res_settings->fetchRow(MYSQL_ASSOC)) |
219 | 220 |
{ |
221 |
$passed = false; |
|
220 | 222 |
$setting_name = $setting['name']; |
221 |
$old_settings[$setting_name] = $setting['value']; |
|
222 |
$value = $admin->get_post($setting_name); |
|
223 |
$value = isset($_POST[$setting_name]) ? $value : $old_settings[$setting_name] ; |
|
223 |
// $old_settings = $setting['value']; |
|
224 |
// $value = $admin->get_post($setting_name); |
|
225 |
if(($value = $admin->get_post($setting_name)) === null) { continue; } |
|
226 |
// $value = isset($_POST[$setting_name]) ? $value : $old_settings ; |
|
224 | 227 |
switch ($setting_name) { |
225 | 228 |
case 'default_timezone': |
226 |
$value = (is_numeric($value) ? $value : 0);
|
|
227 |
$value = ( ($value >= -12 && $value <= 13) ? $value :0 ) * 3600;
|
|
228 |
$passed = true;
|
|
229 |
$value = intval($value);
|
|
230 |
$value = ( ($value >= -12 && $value <= 13) ? $value :0 ) * 3600;
|
|
231 |
$passed = ($value != $setting['value']);
|
|
229 | 232 |
break; |
230 | 233 |
case 'string_dir_mode': |
231 | 234 |
$value=$dir_mode; |
232 |
$passed = true;
|
|
235 |
$passed = ($value != $setting['value']);
|
|
233 | 236 |
break; |
234 | 237 |
case 'string_file_mode': |
235 | 238 |
$value=$file_mode; |
236 |
$passed = true; |
|
237 |
break; |
|
239 |
$passed = ($value != $setting['value']); |
|
240 |
break; |
|
241 |
case 'page_extension': |
|
242 |
$value = $admin->StripCodeFromText($value); |
|
243 |
if(!preg_match('/^\.[a-z][a-z0-9]+$/siu', $value)) { |
|
244 |
$value = '.php'; |
|
245 |
} |
|
246 |
$passed = ($value != $setting['value']); |
|
247 |
break; |
|
238 | 248 |
case 'sec_anchor': |
239 |
$value = $admin->StripCodeFromText($value);
|
|
240 |
$value=(($value=='') ? 'section_' : $value);
|
|
241 |
$passed = true;
|
|
249 |
$value = $admin->StripCodeFromText($value);
|
|
250 |
$value=(($value=='') ? 'Sec' : $value);
|
|
251 |
$passed = ($value != $setting['value']);
|
|
242 | 252 |
break; |
243 | 253 |
case 'media_directory': |
244 |
$value = ( (strpos($value,'/',0)===false) && ($value!= '') ) ? '/'.$value : rtrim($value,'/'); |
|
245 |
$passed = true; |
|
254 |
$value = trim($value,'/'); |
|
255 |
$value = ( ($value != '') ? '/'.$value : '/media' ); |
|
256 |
$passed = ($value != $setting['value']); |
|
246 | 257 |
break; |
247 |
case 'pages_directory': |
|
248 |
if( ($database->get_one('SELECT COUNT(*) FROM `'.TABLE_PREFIX.'pages`'))==0 ) { |
|
249 |
$value = rtrim($admin->StripCodeFromText($value)); |
|
250 |
$passed = true; |
|
258 |
case 'pages_directory': |
|
259 |
$sql = 'SELECT COUNT(*) FROM `'.TABLE_PREFIX.'pages`'; |
|
260 |
if( !($database->get_one($sql)) ) { |
|
261 |
$value = rtrim($admin->StripCodeFromText($value)); |
|
262 |
$passed = ($value != $setting['value']); |
|
263 |
} |
|
264 |
$value = trim($value,'/'); |
|
265 |
$value = ( ($value != '') ? '/'.$value : '' ); |
|
266 |
break; |
|
267 |
default : |
|
268 |
if($value == '') { |
|
269 |
$passed = ((in_array($setting_name, $allow_empty_values)) && ($value != $setting['value'])); |
|
251 | 270 |
} else { |
252 |
$value = rtrim($old_settings[$setting_name]); |
|
271 |
if(in_array($setting_name, $StripCodeFromInput) ) { |
|
272 |
$value = trim($admin->StripCodeFromText($value)); |
|
273 |
} |
|
274 |
$passed = (($value != '') && ($value != $setting['value'])); |
|
253 | 275 |
} |
254 |
$value = ( (strpos($value,'/',0)===false) && ($value != '') ? '/'.$value : rtrim($value,'/') ); |
|
255 | 276 |
break; |
256 |
case 'wbmailer_smtp_auth': |
|
257 |
$value = true ; |
|
258 |
$passed = true; |
|
259 |
break; |
|
260 |
default : |
|
261 |
$passed = in_array($setting_name, $allow_empty_values); |
|
262 |
if(in_array($setting_name, $StripCodeFromInput) ) { |
|
263 |
$value = $admin->StripCodeFromText($value); |
|
264 |
} |
|
265 |
break; |
|
266 | 277 |
} |
267 | 278 |
|
268 | 279 |
if (!in_array($setting_name, $allow_tags_in_fields)) |
269 | 280 |
{ |
270 | 281 |
$value = strip_tags($value); |
271 | 282 |
} |
272 |
|
|
273 |
if ( !in_array($value, $disallow_in_fields) && (isset($_POST[$setting_name]) || $passed == true) )
|
|
283 |
if( !in_array($setting_name, $aPreventFromUpdate) && $passed ) |
|
284 |
// if ( !in_array($setting_name, $aPreventFromUpdate) && (isset($_POST[$setting_name]) || $passed == true) )
|
|
274 | 285 |
{ |
275 | 286 |
$value = trim($database->escapeString($value)); |
276 | 287 |
$sql = 'UPDATE `'.TABLE_PREFIX.'settings` '; |
... | ... | |
282 | 293 |
if($database->is_error()) { |
283 | 294 |
$admin->print_error($database->get_error, $js_back ); |
284 | 295 |
} |
285 |
} |
|
296 |
}
|
|
286 | 297 |
} |
287 | 298 |
} |
299 |
$iQueriesDone = $database->getQueryCount - $iQueryStart; |
|
300 |
} |
|
288 | 301 |
|
289 |
} |
|
290 | 302 |
/** |
291 | 303 |
* now save search settings |
292 | 304 |
*/ |
... | ... | |
391 | 403 |
if($database->is_error()) { |
392 | 404 |
$admin->print_error($database->get_error, $js_back ); |
393 | 405 |
} else { |
406 |
// $admin->print_success($iQueriesDone.' Queries '.$MESSAGE['SETTINGS_SAVED'], $js_back ); |
|
394 | 407 |
$admin->print_success($MESSAGE['SETTINGS_SAVED'], $js_back ); |
395 | 408 |
} |
396 | 409 |
$admin->print_footer(); |
Also available in: Unified diff
! /admin/preferences/index.php change to new Translate class
languages only given for existing page languages
! /admin/settings/ change to new Translate class