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 1430 2011-02-11 02:58:45Z Luisehahne $
|
14
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/settings/save.php $
|
15
|
* @lastmodified $Date: 2011-02-11 03:58:45 +0100 (Fri, 11 Feb 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
|
if($advanced == '')
|
30
|
{
|
31
|
$admin = new admin('Settings', 'settings_basic');
|
32
|
} else {
|
33
|
$admin = new admin('Settings', 'settings_advanced');
|
34
|
}
|
35
|
|
36
|
// Create a javascript back link
|
37
|
$js_back = ADMIN_URL.'/settings/index.php'.$advanced;
|
38
|
|
39
|
if( !$admin->checkFTAN() )
|
40
|
{
|
41
|
$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'],$js_back );
|
42
|
exit();
|
43
|
}
|
44
|
|
45
|
// Ensure that the specified default email is formally valid
|
46
|
if(isset($_POST['server_email']))
|
47
|
{
|
48
|
$_POST['server_email'] = strip_tags($_POST['server_email']);
|
49
|
// $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';
|
50
|
$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}))$/';
|
51
|
if(false == preg_match($pattern, $_POST['server_email']))
|
52
|
{
|
53
|
$admin->print_error($MESSAGE['USERS']['INVALID_EMAIL'].
|
54
|
'<br /><strong>Email: '.htmlentities($_POST['server_email']).'</strong>', $js_back);
|
55
|
}
|
56
|
}
|
57
|
|
58
|
// Work-out file mode
|
59
|
if($advanced == '')
|
60
|
{
|
61
|
// Check if should be set to 777 or left alone
|
62
|
if(isset($_POST['world_writeable']) && $_POST['world_writeable'] == 'true')
|
63
|
{
|
64
|
$file_mode = '0777';
|
65
|
$dir_mode = '0777';
|
66
|
} else {
|
67
|
$file_mode = STRING_FILE_MODE;
|
68
|
$dir_mode = STRING_DIR_MODE;
|
69
|
}
|
70
|
} else {
|
71
|
// Work-out the octal value for file mode
|
72
|
$u = 0;
|
73
|
if(isset($_POST['file_u_r']) && $_POST['file_u_r'] == 'true') {
|
74
|
$u = $u+4;
|
75
|
}
|
76
|
if(isset($_POST['file_u_w']) && $_POST['file_u_w'] == 'true') {
|
77
|
$u = $u+2;
|
78
|
}
|
79
|
if(isset($_POST['file_u_e']) && $_POST['file_u_e'] == 'true') {
|
80
|
$u = $u+1;
|
81
|
}
|
82
|
$g = 0;
|
83
|
if(isset($_POST['file_g_r']) && $_POST['file_g_r'] == 'true') {
|
84
|
$g = $g+4;
|
85
|
}
|
86
|
if(isset($_POST['file_g_w']) && $_POST['file_g_w'] == 'true') {
|
87
|
$g = $g+2;
|
88
|
}
|
89
|
if(isset($_POST['file_g_e']) && $_POST['file_g_e'] == 'true') {
|
90
|
$g = $g+1;
|
91
|
}
|
92
|
$o = 0;
|
93
|
if(isset($_POST['file_o_r']) && $_POST['file_o_r'] == 'true') {
|
94
|
$o = $o+4;
|
95
|
}
|
96
|
if(isset($_POST['file_o_w']) && $_POST['file_o_w'] == 'true') {
|
97
|
$o = $o+2;
|
98
|
}
|
99
|
if(isset($_POST['file_o_e']) && $_POST['file_o_e'] == 'true') {
|
100
|
$o = $o+1;
|
101
|
}
|
102
|
$file_mode = "0".$u.$g.$o;
|
103
|
// Work-out the octal value for dir mode
|
104
|
$u = 0;
|
105
|
if(isset($_POST['dir_u_r']) && $_POST['dir_u_r'] == 'true') {
|
106
|
$u = $u+4;
|
107
|
}
|
108
|
if(isset($_POST['dir_u_w']) && $_POST['dir_u_w'] == 'true') {
|
109
|
$u = $u+2;
|
110
|
}
|
111
|
if(isset($_POST['dir_u_e']) && $_POST['dir_u_e'] == 'true') {
|
112
|
$u = $u+1;
|
113
|
}
|
114
|
$g = 0;
|
115
|
if(isset($_POST['dir_g_r']) && $_POST['dir_g_r'] == 'true') {
|
116
|
$g = $g+4;
|
117
|
}
|
118
|
if(isset($_POST['dir_g_w']) && $_POST['dir_g_w'] == 'true') {
|
119
|
$g = $g+2;
|
120
|
}
|
121
|
if(isset($_POST['dir_g_e']) && $_POST['dir_g_e'] == 'true') {
|
122
|
$g = $g+1;
|
123
|
}
|
124
|
$o = 0;
|
125
|
if(isset($_POST['dir_o_r']) && $_POST['dir_o_r'] == 'true') {
|
126
|
$o = $o+4;
|
127
|
}
|
128
|
if(isset($_POST['dir_o_w']) && $_POST['dir_o_w'] == 'true') {
|
129
|
$o = $o+2;
|
130
|
}
|
131
|
if(isset($_POST['dir_o_e']) && $_POST['dir_o_e'] == 'true') {
|
132
|
$o = $o+1;
|
133
|
}
|
134
|
$dir_mode = "0".$u.$g.$o;
|
135
|
}
|
136
|
|
137
|
$allow_tags_in_fields = array('website_header', 'website_footer');
|
138
|
$allow_empty_values = array('website_header','website_footer','sec_anchor','pages_directory','page_spacer');
|
139
|
$disallow_in_fields = array('pages_directory', 'media_directory','wb_version');
|
140
|
// Create new database object
|
141
|
/*$database = new database(); */
|
142
|
|
143
|
// Query current settings in the db, then loop through them and update the db with the new value
|
144
|
$settings = array();
|
145
|
$old_settings = array();
|
146
|
// Query current settings in the db, then loop through them to get old values
|
147
|
$sql = 'SELECT `name`, `value` FROM `'.TABLE_PREFIX.'settings`';
|
148
|
$sql .= 'ORDER BY `name`';
|
149
|
|
150
|
$res_settings = $database->query($sql);
|
151
|
$passed = false;
|
152
|
while($setting = $res_settings->fetchRow())
|
153
|
{
|
154
|
$old_settings[$setting['name']] = $setting['value'];
|
155
|
$setting_name = $setting['name'];
|
156
|
$value = $admin->get_post($setting_name);
|
157
|
$value = isset($_POST[$setting_name]) ? $value : $old_settings[$setting_name] ;
|
158
|
switch ($setting_name) {
|
159
|
case 'default_timezone':
|
160
|
$value=$value*60*60;
|
161
|
$passed = true;
|
162
|
break;
|
163
|
case 'string_dir_mode':
|
164
|
$value=$dir_mode;
|
165
|
$passed = true;
|
166
|
break;
|
167
|
case 'string_file_mode':
|
168
|
$value=$file_mode;
|
169
|
$passed = true;
|
170
|
break;
|
171
|
case 'pages_directory':
|
172
|
break;
|
173
|
default :
|
174
|
$passed = in_array($setting_name, $allow_empty_values);
|
175
|
break;
|
176
|
}
|
177
|
if (!in_array($setting_name, $allow_tags_in_fields))
|
178
|
{
|
179
|
$value = strip_tags($value);
|
180
|
}
|
181
|
|
182
|
|
183
|
if ( !in_array($value, $disallow_in_fields) && (isset($_POST[$setting_name]) || $passed == true) )
|
184
|
{
|
185
|
$value = trim($admin->add_slashes($value));
|
186
|
$sql = 'UPDATE `'.TABLE_PREFIX.'settings` ';
|
187
|
$sql .= 'SET `value` = \''.$value.'\' ';
|
188
|
$sql .= 'WHERE `name` <> \'wb_version\' ';
|
189
|
$sql .= 'AND `name` = \''.$setting_name.'\' ';
|
190
|
|
191
|
if (!$database->query($sql))
|
192
|
{
|
193
|
if($database->is_error()) {
|
194
|
$admin->print_error($database->get_error, $js_back );
|
195
|
}
|
196
|
}
|
197
|
}
|
198
|
}
|
199
|
|
200
|
// Query current search settings in the db, then loop through them and update the db with the new value
|
201
|
$sql = 'SELECT `name`, `value` FROM `'.TABLE_PREFIX.'search` ';
|
202
|
$sql .= 'WHERE `extra` = ""';
|
203
|
$res_search = $database->query($sql);
|
204
|
|
205
|
if($database->is_error()) {
|
206
|
$admin->print_error($database->is_error(), $js_back );
|
207
|
}
|
208
|
|
209
|
while($search_setting = $res_search->fetchRow())
|
210
|
{
|
211
|
$old_value = $search_setting['value'];
|
212
|
$setting_name = $search_setting['name'];
|
213
|
$post_name = 'search_'.$search_setting['name'];
|
214
|
|
215
|
// hold old value if post is empty
|
216
|
// check search template
|
217
|
$value = ( ($admin->get_post($post_name) == '') && ($setting_name != 'template') ) ? $old_value : $admin->get_post($post_name);
|
218
|
// $value = ( ($admin->get_post($post_name) == '') && ($setting_name == 'template') ) ? DEFAULT_TEMPLATE : $admin->get_post($post_name);
|
219
|
if(isset($value))
|
220
|
{
|
221
|
$value = $admin->add_slashes($value);
|
222
|
$sql = 'UPDATE `'.TABLE_PREFIX.'search` ';
|
223
|
$sql .= 'SET `value` = "'.$value.'" ';
|
224
|
$sql .= 'WHERE `name` = "'.$setting_name.'" ';
|
225
|
$sql .= 'AND `extra` = ""';
|
226
|
if($database->query($sql)) {
|
227
|
}
|
228
|
$sql_info = mysql_info($database->db_handle);
|
229
|
}
|
230
|
}
|
231
|
|
232
|
// Check if there was an error updating the db
|
233
|
if($database->is_error()) {
|
234
|
$admin->print_error($database->get_error, $js_back );
|
235
|
} else {
|
236
|
$admin->print_success($MESSAGE['SETTINGS']['SAVED'], $js_back );
|
237
|
}
|
238
|
$admin->print_footer();
|
239
|
|
240
|
?>
|