1
|
<?php
|
2
|
/**
|
3
|
*
|
4
|
* @category admin
|
5
|
* @package settings
|
6
|
* @author WebsiteBaker Project
|
7
|
* @copyright 2004-2009, Ryan Djurovich
|
8
|
* @copyright 2009-2011, Website Baker Org. e.V.
|
9
|
* @link http://www.websitebaker2.org/
|
10
|
* @license http://www.gnu.org/licenses/gpl.html
|
11
|
* @platform WebsiteBaker 2.8.x
|
12
|
* @requirements PHP 5.2.2 and higher
|
13
|
* @version $Id: save.php 1457 2011-06-25 17:18:50Z Luisehahne $
|
14
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/settings/save.php $
|
15
|
* @lastmodified $Date: 2011-06-25 19:18:50 +0200 (Sat, 25 Jun 2011) $
|
16
|
*
|
17
|
*/
|
18
|
|
19
|
// prevent this file from being accessed directly in the browser (would set all entries in DB settings table to '')
|
20
|
if(!isset($_POST['default_language']) || $_POST['default_language'] == '') die(header('Location: index.php'));
|
21
|
|
22
|
// Find out if the user was view advanced options or not
|
23
|
$advanced = ($_POST['advanced'] == 'yes') ? '?advanced=yes' : '';
|
24
|
|
25
|
// Print admin header
|
26
|
require('../../config.php');
|
27
|
require_once(WB_PATH.'/framework/class.admin.php');
|
28
|
|
29
|
// suppress to print the header, so no new FTAN will be set
|
30
|
if($advanced == '')
|
31
|
{
|
32
|
$admin = new admin('Settings', 'settings_basic',false);
|
33
|
} else {
|
34
|
$admin = new admin('Settings', 'settings_advanced',false);
|
35
|
}
|
36
|
|
37
|
// Create a javascript back link
|
38
|
$js_back = ADMIN_URL.'/settings/index.php'.$advanced;
|
39
|
if( !$admin->checkFTAN() )
|
40
|
{
|
41
|
$admin->print_header();
|
42
|
$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'],$js_back );
|
43
|
}
|
44
|
// After check print the header
|
45
|
$admin->print_header();
|
46
|
|
47
|
// Ensure that the specified default email is formally valid
|
48
|
if(isset($_POST['server_email']))
|
49
|
{
|
50
|
$_POST['server_email'] = strip_tags($_POST['server_email']);
|
51
|
// $pattern = '/^[-a-z0-9~!$%^&*_=+}{\'?]+(\.[-a-z0-9~!$%^&*_=+}{\'?]+)*@([a-z0-9]([-a-z0-9_]?[a-z0-9])*(\.[-a-z0-9_]+)*\.(aero|arpa|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro|travel|mobi|[a-z]{2})|([1]?\d{1,2}|2[0-4]{1}\d{1}|25[0-5]{1})(\.([1]?\d{1,2}|2[0-4]{1}\d{1}|25[0-5]{1})){3})(:[0-9]{1,5})?\r/im';
|
52
|
$pattern = '/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.(([0-9]{1,3})|([a-zA-Z]{2,6}))$/';
|
53
|
if(false == preg_match($pattern, $_POST['server_email']))
|
54
|
{
|
55
|
$admin->print_error($MESSAGE['USERS']['INVALID_EMAIL'].
|
56
|
'<br /><strong>Email: '.htmlentities($_POST['server_email']).'</strong>', $js_back);
|
57
|
}
|
58
|
}
|
59
|
|
60
|
// Work-out file mode
|
61
|
if($advanced == '')
|
62
|
{
|
63
|
// Check if should be set to 777 or left alone
|
64
|
if(isset($_POST['world_writeable']) && $_POST['world_writeable'] == 'true')
|
65
|
{
|
66
|
$file_mode = '0777';
|
67
|
$dir_mode = '0777';
|
68
|
} else {
|
69
|
$file_mode = STRING_FILE_MODE;
|
70
|
$dir_mode = STRING_DIR_MODE;
|
71
|
}
|
72
|
} else {
|
73
|
// Work-out the octal value for file mode
|
74
|
$u = 0;
|
75
|
if(isset($_POST['file_u_r']) && $_POST['file_u_r'] == 'true') {
|
76
|
$u = $u+4;
|
77
|
}
|
78
|
if(isset($_POST['file_u_w']) && $_POST['file_u_w'] == 'true') {
|
79
|
$u = $u+2;
|
80
|
}
|
81
|
if(isset($_POST['file_u_e']) && $_POST['file_u_e'] == 'true') {
|
82
|
$u = $u+1;
|
83
|
}
|
84
|
$g = 0;
|
85
|
if(isset($_POST['file_g_r']) && $_POST['file_g_r'] == 'true') {
|
86
|
$g = $g+4;
|
87
|
}
|
88
|
if(isset($_POST['file_g_w']) && $_POST['file_g_w'] == 'true') {
|
89
|
$g = $g+2;
|
90
|
}
|
91
|
if(isset($_POST['file_g_e']) && $_POST['file_g_e'] == 'true') {
|
92
|
$g = $g+1;
|
93
|
}
|
94
|
$o = 0;
|
95
|
if(isset($_POST['file_o_r']) && $_POST['file_o_r'] == 'true') {
|
96
|
$o = $o+4;
|
97
|
}
|
98
|
if(isset($_POST['file_o_w']) && $_POST['file_o_w'] == 'true') {
|
99
|
$o = $o+2;
|
100
|
}
|
101
|
if(isset($_POST['file_o_e']) && $_POST['file_o_e'] == 'true') {
|
102
|
$o = $o+1;
|
103
|
}
|
104
|
$file_mode = "0".$u.$g.$o;
|
105
|
// Work-out the octal value for dir mode
|
106
|
$u = 0;
|
107
|
if(isset($_POST['dir_u_r']) && $_POST['dir_u_r'] == 'true') {
|
108
|
$u = $u+4;
|
109
|
}
|
110
|
if(isset($_POST['dir_u_w']) && $_POST['dir_u_w'] == 'true') {
|
111
|
$u = $u+2;
|
112
|
}
|
113
|
if(isset($_POST['dir_u_e']) && $_POST['dir_u_e'] == 'true') {
|
114
|
$u = $u+1;
|
115
|
}
|
116
|
$g = 0;
|
117
|
if(isset($_POST['dir_g_r']) && $_POST['dir_g_r'] == 'true') {
|
118
|
$g = $g+4;
|
119
|
}
|
120
|
if(isset($_POST['dir_g_w']) && $_POST['dir_g_w'] == 'true') {
|
121
|
$g = $g+2;
|
122
|
}
|
123
|
if(isset($_POST['dir_g_e']) && $_POST['dir_g_e'] == 'true') {
|
124
|
$g = $g+1;
|
125
|
}
|
126
|
$o = 0;
|
127
|
if(isset($_POST['dir_o_r']) && $_POST['dir_o_r'] == 'true') {
|
128
|
$o = $o+4;
|
129
|
}
|
130
|
if(isset($_POST['dir_o_w']) && $_POST['dir_o_w'] == 'true') {
|
131
|
$o = $o+2;
|
132
|
}
|
133
|
if(isset($_POST['dir_o_e']) && $_POST['dir_o_e'] == 'true') {
|
134
|
$o = $o+1;
|
135
|
}
|
136
|
$dir_mode = "0".$u.$g.$o;
|
137
|
}
|
138
|
|
139
|
$allow_tags_in_fields = array('website_header', 'website_footer');
|
140
|
$allow_empty_values = array('website_header','website_footer','sec_anchor','pages_directory','page_spacer');
|
141
|
$disallow_in_fields = array('pages_directory', 'media_directory','wb_version');
|
142
|
// Create new database object
|
143
|
/*$database = new database(); */
|
144
|
|
145
|
// Query current settings in the db, then loop through them and update the db with the new value
|
146
|
$settings = array();
|
147
|
$old_settings = array();
|
148
|
// Query current settings in the db, then loop through them to get old values
|
149
|
$sql = 'SELECT `name`, `value` FROM `'.TABLE_PREFIX.'settings`';
|
150
|
$sql .= 'ORDER BY `name`';
|
151
|
|
152
|
$res_settings = $database->query($sql);
|
153
|
$passed = false;
|
154
|
while($setting = $res_settings->fetchRow())
|
155
|
{
|
156
|
$old_settings[$setting['name']] = $setting['value'];
|
157
|
$setting_name = $setting['name'];
|
158
|
$value = $admin->get_post($setting_name);
|
159
|
$value = isset($_POST[$setting_name]) ? $value : $old_settings[$setting_name] ;
|
160
|
switch ($setting_name) {
|
161
|
case 'default_timezone':
|
162
|
$value=$value*60*60;
|
163
|
$passed = true;
|
164
|
break;
|
165
|
case 'string_dir_mode':
|
166
|
$value=$dir_mode;
|
167
|
$passed = true;
|
168
|
break;
|
169
|
case 'string_file_mode':
|
170
|
$value=$file_mode;
|
171
|
$passed = true;
|
172
|
break;
|
173
|
case 'pages_directory':
|
174
|
break;
|
175
|
default :
|
176
|
$passed = in_array($setting_name, $allow_empty_values);
|
177
|
break;
|
178
|
}
|
179
|
if (!in_array($setting_name, $allow_tags_in_fields))
|
180
|
{
|
181
|
$value = strip_tags($value);
|
182
|
}
|
183
|
|
184
|
|
185
|
if ( !in_array($value, $disallow_in_fields) && (isset($_POST[$setting_name]) || $passed == true) )
|
186
|
{
|
187
|
$value = trim($admin->add_slashes($value));
|
188
|
$sql = 'UPDATE `'.TABLE_PREFIX.'settings` ';
|
189
|
$sql .= 'SET `value` = \''.$value.'\' ';
|
190
|
$sql .= 'WHERE `name` <> \'wb_version\' ';
|
191
|
$sql .= 'AND `name` = \''.$setting_name.'\' ';
|
192
|
|
193
|
if (!$database->query($sql))
|
194
|
{
|
195
|
if($database->is_error()) {
|
196
|
$admin->print_error($database->get_error, $js_back );
|
197
|
}
|
198
|
}
|
199
|
}
|
200
|
}
|
201
|
|
202
|
// Query current search settings in the db, then loop through them and update the db with the new value
|
203
|
$sql = 'SELECT `name`, `value` FROM `'.TABLE_PREFIX.'search` ';
|
204
|
$sql .= 'WHERE `extra` = ""';
|
205
|
$res_search = $database->query($sql);
|
206
|
|
207
|
if($database->is_error()) {
|
208
|
$admin->print_error($database->is_error(), $js_back );
|
209
|
}
|
210
|
|
211
|
while($search_setting = $res_search->fetchRow())
|
212
|
{
|
213
|
$old_value = $search_setting['value'];
|
214
|
$setting_name = $search_setting['name'];
|
215
|
$post_name = 'search_'.$search_setting['name'];
|
216
|
|
217
|
// hold old value if post is empty
|
218
|
// check search template
|
219
|
$value = ( ($admin->get_post($post_name) == '') && ($setting_name != 'template') ) ? $old_value : $admin->get_post($post_name);
|
220
|
// $value = ( ($admin->get_post($post_name) == '') && ($setting_name == 'template') ) ? DEFAULT_TEMPLATE : $admin->get_post($post_name);
|
221
|
if(isset($value))
|
222
|
{
|
223
|
$value = $admin->add_slashes($value);
|
224
|
$sql = 'UPDATE `'.TABLE_PREFIX.'search` ';
|
225
|
$sql .= 'SET `value` = "'.$value.'" ';
|
226
|
$sql .= 'WHERE `name` = "'.$setting_name.'" ';
|
227
|
$sql .= 'AND `extra` = ""';
|
228
|
if($database->query($sql)) {
|
229
|
}
|
230
|
$sql_info = mysql_info($database->db_handle);
|
231
|
}
|
232
|
}
|
233
|
|
234
|
// Check if there was an error updating the db
|
235
|
if($database->is_error()) {
|
236
|
$admin->print_error($database->get_error, $js_back );
|
237
|
} else {
|
238
|
$admin->print_success($MESSAGE['SETTINGS']['SAVED'], $js_back );
|
239
|
}
|
240
|
$admin->print_footer();
|
241
|
|
242
|
?>
|