Revision 1335
Added by Luisehahne over 14 years ago
save.php | ||
---|---|---|
20 | 20 |
if(!isset($_POST['default_language']) || $_POST['default_language'] == '') die(header('Location: index.php')); |
21 | 21 |
|
22 | 22 |
// Find out if the user was view advanced options or not |
23 |
if($_POST['advanced'] == 'yes' ? $advanced = '?advanced=yes' : $advanced = '');
|
|
23 |
$advanced = ($_POST['advanced'] == 'yes') ? '?advanced=yes' : '';
|
|
24 | 24 |
|
25 | 25 |
// Print admin header |
26 | 26 |
require('../../config.php'); |
27 | 27 |
require_once(WB_PATH.'/framework/class.admin.php'); |
28 |
|
|
28 | 29 |
if($advanced == '') |
29 | 30 |
{ |
30 | 31 |
$admin = new admin('Settings', 'settings_basic'); |
... | ... | |
53 | 54 |
if($advanced == '') |
54 | 55 |
{ |
55 | 56 |
// Check if should be set to 777 or left alone |
56 |
if(isset($_POST['world_writeable']) AND $_POST['world_writeable'] == 'true')
|
|
57 |
if(isset($_POST['world_writeable']) && $_POST['world_writeable'] == 'true')
|
|
57 | 58 |
{ |
58 | 59 |
$file_mode = '0777'; |
59 | 60 |
$dir_mode = '0777'; |
... | ... | |
64 | 65 |
} else { |
65 | 66 |
// Work-out the octal value for file mode |
66 | 67 |
$u = 0; |
67 |
if(isset($_POST['file_u_r']) AND $_POST['file_u_r'] == 'true') {
|
|
68 |
if(isset($_POST['file_u_r']) && $_POST['file_u_r'] == 'true') {
|
|
68 | 69 |
$u = $u+4; |
69 | 70 |
} |
70 |
if(isset($_POST['file_u_w']) AND $_POST['file_u_w'] == 'true') {
|
|
71 |
if(isset($_POST['file_u_w']) && $_POST['file_u_w'] == 'true') {
|
|
71 | 72 |
$u = $u+2; |
72 | 73 |
} |
73 |
if(isset($_POST['file_u_e']) AND $_POST['file_u_e'] == 'true') {
|
|
74 |
if(isset($_POST['file_u_e']) && $_POST['file_u_e'] == 'true') {
|
|
74 | 75 |
$u = $u+1; |
75 | 76 |
} |
76 | 77 |
$g = 0; |
77 |
if(isset($_POST['file_g_r']) AND $_POST['file_g_r'] == 'true') {
|
|
78 |
if(isset($_POST['file_g_r']) && $_POST['file_g_r'] == 'true') {
|
|
78 | 79 |
$g = $g+4; |
79 | 80 |
} |
80 |
if(isset($_POST['file_g_w']) AND $_POST['file_g_w'] == 'true') {
|
|
81 |
if(isset($_POST['file_g_w']) && $_POST['file_g_w'] == 'true') {
|
|
81 | 82 |
$g = $g+2; |
82 | 83 |
} |
83 |
if(isset($_POST['file_g_e']) AND $_POST['file_g_e'] == 'true') {
|
|
84 |
if(isset($_POST['file_g_e']) && $_POST['file_g_e'] == 'true') {
|
|
84 | 85 |
$g = $g+1; |
85 | 86 |
} |
86 | 87 |
$o = 0; |
87 |
if(isset($_POST['file_o_r']) AND $_POST['file_o_r'] == 'true') {
|
|
88 |
if(isset($_POST['file_o_r']) && $_POST['file_o_r'] == 'true') {
|
|
88 | 89 |
$o = $o+4; |
89 | 90 |
} |
90 |
if(isset($_POST['file_o_w']) AND $_POST['file_o_w'] == 'true') {
|
|
91 |
if(isset($_POST['file_o_w']) && $_POST['file_o_w'] == 'true') {
|
|
91 | 92 |
$o = $o+2; |
92 | 93 |
} |
93 |
if(isset($_POST['file_o_e']) AND $_POST['file_o_e'] == 'true') {
|
|
94 |
if(isset($_POST['file_o_e']) && $_POST['file_o_e'] == 'true') {
|
|
94 | 95 |
$o = $o+1; |
95 | 96 |
} |
96 | 97 |
$file_mode = "0".$u.$g.$o; |
97 | 98 |
// Work-out the octal value for dir mode |
98 | 99 |
$u = 0; |
99 |
if(isset($_POST['dir_u_r']) AND $_POST['dir_u_r'] == 'true') {
|
|
100 |
if(isset($_POST['dir_u_r']) && $_POST['dir_u_r'] == 'true') {
|
|
100 | 101 |
$u = $u+4; |
101 | 102 |
} |
102 |
if(isset($_POST['dir_u_w']) AND $_POST['dir_u_w'] == 'true') {
|
|
103 |
if(isset($_POST['dir_u_w']) && $_POST['dir_u_w'] == 'true') {
|
|
103 | 104 |
$u = $u+2; |
104 | 105 |
} |
105 |
if(isset($_POST['dir_u_e']) AND $_POST['dir_u_e'] == 'true') {
|
|
106 |
if(isset($_POST['dir_u_e']) && $_POST['dir_u_e'] == 'true') {
|
|
106 | 107 |
$u = $u+1; |
107 | 108 |
} |
108 | 109 |
$g = 0; |
109 |
if(isset($_POST['dir_g_r']) AND $_POST['dir_g_r'] == 'true') {
|
|
110 |
if(isset($_POST['dir_g_r']) && $_POST['dir_g_r'] == 'true') {
|
|
110 | 111 |
$g = $g+4; |
111 | 112 |
} |
112 |
if(isset($_POST['dir_g_w']) AND $_POST['dir_g_w'] == 'true') {
|
|
113 |
if(isset($_POST['dir_g_w']) && $_POST['dir_g_w'] == 'true') {
|
|
113 | 114 |
$g = $g+2; |
114 | 115 |
} |
115 |
if(isset($_POST['dir_g_e']) AND $_POST['dir_g_e'] == 'true') {
|
|
116 |
if(isset($_POST['dir_g_e']) && $_POST['dir_g_e'] == 'true') {
|
|
116 | 117 |
$g = $g+1; |
117 | 118 |
} |
118 | 119 |
$o = 0; |
119 |
if(isset($_POST['dir_o_r']) AND $_POST['dir_o_r'] == 'true') {
|
|
120 |
if(isset($_POST['dir_o_r']) && $_POST['dir_o_r'] == 'true') {
|
|
120 | 121 |
$o = $o+4; |
121 | 122 |
} |
122 |
if(isset($_POST['dir_o_w']) AND $_POST['dir_o_w'] == 'true') {
|
|
123 |
if(isset($_POST['dir_o_w']) && $_POST['dir_o_w'] == 'true') {
|
|
123 | 124 |
$o = $o+2; |
124 | 125 |
} |
125 |
if(isset($_POST['dir_o_e']) AND $_POST['dir_o_e'] == 'true') {
|
|
126 |
if(isset($_POST['dir_o_e']) && $_POST['dir_o_e'] == 'true') {
|
|
126 | 127 |
$o = $o+1; |
127 | 128 |
} |
128 | 129 |
$dir_mode = "0".$u.$g.$o; |
... | ... | |
138 | 139 |
{ |
139 | 140 |
$setting_name = $setting['name']; |
140 | 141 |
$value = $admin->get_post($setting_name); |
141 |
if ($setting_name!='wb_version') |
|
142 |
{ |
|
143 |
$allow_tags_in_fields = array('website_header', 'website_footer','wbmailer_smtp_password'); |
|
144 |
if(!in_array($setting_name, $allow_tags_in_fields)) { |
|
145 |
$value = strip_tags($value); |
|
142 |
if(isset($value)) |
|
143 |
{ |
|
144 |
if ($setting_name!='wb_version') |
|
145 |
{ |
|
146 |
$allow_tags_in_fields = array('website_header', 'website_footer','wbmailer_smtp_password'); |
|
147 |
if(!in_array($setting_name, $allow_tags_in_fields)) { |
|
148 |
$value = strip_tags($value); |
|
149 |
} |
|
150 |
switch ($setting_name) { |
|
151 |
case 'default_timezone': |
|
152 |
$value=$value*60*60; |
|
153 |
break; |
|
154 |
case 'string_dir_mode': |
|
155 |
$value=$dir_mode; |
|
156 |
break; |
|
157 |
case 'string_file_mode': |
|
158 |
$value=$file_mode; |
|
159 |
break; |
|
160 |
case 'pages_directory': |
|
161 |
if(trim($value)=='/') $value=''; |
|
162 |
break; |
|
163 |
} |
|
164 |
$value = $admin->add_slashes($value); |
|
165 |
$database->query("UPDATE ".TABLE_PREFIX."settings SET value = '$value' WHERE name = '$setting_name'"); |
|
146 | 166 |
} |
147 |
switch ($setting_name) { |
|
148 |
case 'default_timezone': |
|
149 |
$value=$value*60*60; |
|
150 |
break; |
|
151 |
case 'string_dir_mode': |
|
152 |
$value=$dir_mode; |
|
153 |
break; |
|
154 |
case 'string_file_mode': |
|
155 |
$value=$file_mode; |
|
156 |
break; |
|
157 |
case 'pages_directory': |
|
158 |
if(trim($value)=='/') $value=''; |
|
159 |
break; |
|
160 |
} |
|
161 |
$value = $admin->add_slashes($value); |
|
162 |
$database->query("UPDATE ".TABLE_PREFIX."settings SET value = '$value' WHERE name = '$setting_name'"); |
|
163 | 167 |
} |
164 | 168 |
} |
165 | 169 |
|
166 | 170 |
// Query current search settings in the db, then loop through them and update the db with the new value |
167 |
$query = "SELECT name, value FROM ".TABLE_PREFIX."search WHERE extra = ''"; |
|
168 |
$results = $database->query($query); |
|
169 |
while($search_setting = $results->fetchRow()) |
|
171 |
$sql = 'SELECT `name`, `value` FROM `'.TABLE_PREFIX.'search` '; |
|
172 |
$sql .= 'WHERE `extra` = ""'; |
|
173 |
$res_search = $database->query($sql); |
|
174 |
|
|
175 |
if($database->is_error()) { |
|
176 |
$admin->print_error($database->is_error(), ADMIN_URL.'/settings/index.php'.$advanced); |
|
177 |
} |
|
178 |
|
|
179 |
while($search_setting = $res_search->fetchRow()) |
|
170 | 180 |
{ |
171 | 181 |
$old_value = $search_setting['value']; |
172 | 182 |
$setting_name = $search_setting['name']; |
173 | 183 |
$post_name = 'search_'.$search_setting['name']; |
184 |
|
|
174 | 185 |
// hold old value if post is empty |
175 | 186 |
// check search template |
176 |
$value = ( ($admin->get_post($post_name) == '') AND ($setting_name != 'template') ) ? $old_value : $admin->get_post($post_name); |
|
177 |
|
|
178 |
$value = $admin->add_slashes($value); |
|
179 |
$database->query("UPDATE ".TABLE_PREFIX."search SET value = '$value' WHERE name = '$setting_name'"); |
|
187 |
$value = ( ($admin->get_post($post_name) == '') && ($setting_name != 'template') ) ? $old_value : $admin->get_post($post_name); |
|
188 |
// $value = ( ($admin->get_post($post_name) == '') && ($setting_name == 'template') ) ? DEFAULT_TEMPLATE : $admin->get_post($post_name); |
|
189 |
if(isset($value)) |
|
190 |
{ |
|
191 |
$value = $admin->add_slashes($value); |
|
192 |
$sql = 'UPDATE `'.TABLE_PREFIX.'search` '; |
|
193 |
$sql .= 'SET `value` = "'.$value.'" '; |
|
194 |
$sql .= 'WHERE `name` = "'.$setting_name.'" '; |
|
195 |
$sql .= 'AND `extra` = ""'; |
|
196 |
if($database->query($sql)) { |
|
197 |
$sql_info = mysql_info($database->db_handle); |
|
198 |
} |
|
199 |
if($database->is_error()) { |
|
200 |
$admin->print_error($database->get_error, ADMIN_URL.'/settings/index.php'.$advanced); |
|
201 |
} |
|
202 |
} |
|
180 | 203 |
} |
181 | 204 |
|
182 | 205 |
// Check if there was an error updating the db |
183 | 206 |
if($database->is_error()) { |
184 | 207 |
$admin->print_error($database->get_error, ADMIN_URL.'/settings/index.php'.$advanced); |
185 |
$admin->print_footer();
|
|
186 |
exit();
|
|
208 |
} else {
|
|
209 |
$admin->print_success($MESSAGE['SETTINGS']['SAVED'], ADMIN_URL.'/settings/index.php'.$advanced);
|
|
187 | 210 |
} |
188 |
|
|
189 |
$admin->print_success($MESSAGE['SETTINGS']['SAVED'], ADMIN_URL.'/settings/index.php'.$advanced); |
|
190 | 211 |
$admin->print_footer(); |
191 | 212 |
|
192 | 213 |
?> |
Also available in: Unified diff
Fixed update search settings
Fixed bug in /modules/admin.php