1 |
1241
|
Luisehahne
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
*
|
4 |
1255
|
Luisehahne
|
* @category admin
|
5 |
|
|
* @package settings
|
6 |
1268
|
Luisehahne
|
* @author WebsiteBaker Project
|
7 |
1255
|
Luisehahne
|
* @copyright 2004-2009, Ryan Djurovich
|
8 |
|
|
* @copyright 2009-2010, 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 4.3.4 and higher
|
13 |
1268
|
Luisehahne
|
* @version $Id$
|
14 |
|
|
* @filesource $HeadURL$
|
15 |
1255
|
Luisehahne
|
* @lastmodified $Date$
|
16 |
|
|
*
|
17 |
1241
|
Luisehahne
|
*/
|
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 |
|
|
if($_POST['advanced'] == 'yes' ? $advanced = '?advanced=yes' : $advanced = '');
|
24 |
|
|
|
25 |
|
|
// Print admin header
|
26 |
|
|
require('../../config.php');
|
27 |
|
|
require_once(WB_PATH.'/framework/class.admin.php');
|
28 |
1301
|
Luisehahne
|
if($advanced == '')
|
29 |
|
|
{
|
30 |
1241
|
Luisehahne
|
$admin = new admin('Settings', 'settings_basic');
|
31 |
|
|
$_POST['database_password'] = DB_PASSWORD;
|
32 |
|
|
} else {
|
33 |
|
|
$admin = new admin('Settings', 'settings_advanced');
|
34 |
|
|
}
|
35 |
|
|
|
36 |
|
|
// Create a javascript back link
|
37 |
|
|
$js_back = "javascript: history.go(-1);";
|
38 |
|
|
|
39 |
|
|
// Ensure that the specified default email is formally valid
|
40 |
1255
|
Luisehahne
|
if(isset($_POST['server_email']))
|
41 |
|
|
{
|
42 |
1241
|
Luisehahne
|
$_POST['server_email'] = strip_tags($_POST['server_email']);
|
43 |
1301
|
Luisehahne
|
$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';
|
44 |
|
|
// $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}))$/';
|
45 |
|
|
if(false == preg_match($pattern, $_POST['server_email']))
|
46 |
|
|
{
|
47 |
1241
|
Luisehahne
|
$admin->print_error($MESSAGE['USERS']['INVALID_EMAIL'].
|
48 |
|
|
'<br /><strong>Email: '.htmlentities($_POST['server_email']).'</strong>', $js_back);
|
49 |
|
|
}
|
50 |
|
|
}
|
51 |
|
|
|
52 |
|
|
// Work-out file mode
|
53 |
1255
|
Luisehahne
|
if($advanced == '')
|
54 |
|
|
{
|
55 |
1241
|
Luisehahne
|
// Check if should be set to 777 or left alone
|
56 |
1255
|
Luisehahne
|
if(isset($_POST['world_writeable']) AND $_POST['world_writeable'] == 'true')
|
57 |
|
|
{
|
58 |
1241
|
Luisehahne
|
$file_mode = '0777';
|
59 |
|
|
$dir_mode = '0777';
|
60 |
|
|
} else {
|
61 |
|
|
$file_mode = STRING_FILE_MODE;
|
62 |
|
|
$dir_mode = STRING_DIR_MODE;
|
63 |
|
|
}
|
64 |
|
|
} else {
|
65 |
|
|
// Work-out the octal value for file mode
|
66 |
|
|
$u = 0;
|
67 |
|
|
if(isset($_POST['file_u_r']) AND $_POST['file_u_r'] == 'true') {
|
68 |
|
|
$u = $u+4;
|
69 |
|
|
}
|
70 |
|
|
if(isset($_POST['file_u_w']) AND $_POST['file_u_w'] == 'true') {
|
71 |
|
|
$u = $u+2;
|
72 |
|
|
}
|
73 |
|
|
if(isset($_POST['file_u_e']) AND $_POST['file_u_e'] == 'true') {
|
74 |
|
|
$u = $u+1;
|
75 |
|
|
}
|
76 |
|
|
$g = 0;
|
77 |
|
|
if(isset($_POST['file_g_r']) AND $_POST['file_g_r'] == 'true') {
|
78 |
|
|
$g = $g+4;
|
79 |
|
|
}
|
80 |
|
|
if(isset($_POST['file_g_w']) AND $_POST['file_g_w'] == 'true') {
|
81 |
|
|
$g = $g+2;
|
82 |
|
|
}
|
83 |
|
|
if(isset($_POST['file_g_e']) AND $_POST['file_g_e'] == 'true') {
|
84 |
|
|
$g = $g+1;
|
85 |
|
|
}
|
86 |
|
|
$o = 0;
|
87 |
|
|
if(isset($_POST['file_o_r']) AND $_POST['file_o_r'] == 'true') {
|
88 |
|
|
$o = $o+4;
|
89 |
|
|
}
|
90 |
|
|
if(isset($_POST['file_o_w']) AND $_POST['file_o_w'] == 'true') {
|
91 |
|
|
$o = $o+2;
|
92 |
|
|
}
|
93 |
|
|
if(isset($_POST['file_o_e']) AND $_POST['file_o_e'] == 'true') {
|
94 |
|
|
$o = $o+1;
|
95 |
|
|
}
|
96 |
|
|
$file_mode = "0".$u.$g.$o;
|
97 |
|
|
// Work-out the octal value for dir mode
|
98 |
|
|
$u = 0;
|
99 |
|
|
if(isset($_POST['dir_u_r']) AND $_POST['dir_u_r'] == 'true') {
|
100 |
|
|
$u = $u+4;
|
101 |
|
|
}
|
102 |
|
|
if(isset($_POST['dir_u_w']) AND $_POST['dir_u_w'] == 'true') {
|
103 |
|
|
$u = $u+2;
|
104 |
|
|
}
|
105 |
|
|
if(isset($_POST['dir_u_e']) AND $_POST['dir_u_e'] == 'true') {
|
106 |
|
|
$u = $u+1;
|
107 |
|
|
}
|
108 |
|
|
$g = 0;
|
109 |
|
|
if(isset($_POST['dir_g_r']) AND $_POST['dir_g_r'] == 'true') {
|
110 |
|
|
$g = $g+4;
|
111 |
|
|
}
|
112 |
|
|
if(isset($_POST['dir_g_w']) AND $_POST['dir_g_w'] == 'true') {
|
113 |
|
|
$g = $g+2;
|
114 |
|
|
}
|
115 |
|
|
if(isset($_POST['dir_g_e']) AND $_POST['dir_g_e'] == 'true') {
|
116 |
|
|
$g = $g+1;
|
117 |
|
|
}
|
118 |
|
|
$o = 0;
|
119 |
|
|
if(isset($_POST['dir_o_r']) AND $_POST['dir_o_r'] == 'true') {
|
120 |
|
|
$o = $o+4;
|
121 |
|
|
}
|
122 |
|
|
if(isset($_POST['dir_o_w']) AND $_POST['dir_o_w'] == 'true') {
|
123 |
|
|
$o = $o+2;
|
124 |
|
|
}
|
125 |
|
|
if(isset($_POST['dir_o_e']) AND $_POST['dir_o_e'] == 'true') {
|
126 |
|
|
$o = $o+1;
|
127 |
|
|
}
|
128 |
|
|
$dir_mode = "0".$u.$g.$o;
|
129 |
|
|
}
|
130 |
|
|
|
131 |
|
|
// Create new database object
|
132 |
1255
|
Luisehahne
|
/*$database = new database(); */
|
133 |
1241
|
Luisehahne
|
|
134 |
|
|
// Query current settings in the db, then loop through them and update the db with the new value
|
135 |
|
|
$query = "SELECT name FROM ".TABLE_PREFIX."settings";
|
136 |
|
|
$results = $database->query($query);
|
137 |
1255
|
Luisehahne
|
while($setting = $results->fetchRow())
|
138 |
|
|
{
|
139 |
1241
|
Luisehahne
|
$setting_name = $setting['name'];
|
140 |
|
|
$value = $admin->get_post($setting_name);
|
141 |
1255
|
Luisehahne
|
if ($setting_name!='wb_version')
|
142 |
|
|
{
|
143 |
1241
|
Luisehahne
|
$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);
|
146 |
|
|
}
|
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 |
|
|
}
|
164 |
|
|
}
|
165 |
|
|
|
166 |
|
|
// 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())
|
170 |
|
|
{
|
171 |
|
|
$old_value = $search_setting['value'];
|
172 |
|
|
$setting_name = $search_setting['name'];
|
173 |
|
|
$post_name = 'search_'.$search_setting['name'];
|
174 |
1255
|
Luisehahne
|
// hold old value if post is empty
|
175 |
|
|
// check search template
|
176 |
|
|
$value = ( ($admin->get_post($post_name) == '') AND ($setting_name != 'template') ) ? $old_value : $admin->get_post($post_name);
|
177 |
1241
|
Luisehahne
|
|
178 |
|
|
$value = $admin->add_slashes($value);
|
179 |
|
|
$database->query("UPDATE ".TABLE_PREFIX."search SET value = '$value' WHERE name = '$setting_name'");
|
180 |
|
|
}
|
181 |
|
|
|
182 |
|
|
// Check if there was an error updating the db
|
183 |
|
|
if($database->is_error()) {
|
184 |
|
|
$admin->print_error($database->get_error, ADMIN_URL.'/settings/index.php'.$advanced);
|
185 |
|
|
$admin->print_footer();
|
186 |
|
|
exit();
|
187 |
|
|
}
|
188 |
|
|
|
189 |
|
|
$admin->print_success($MESSAGE['SETTINGS']['SAVED'], ADMIN_URL.'/settings/index.php'.$advanced);
|
190 |
|
|
$admin->print_footer();
|
191 |
|
|
|
192 |
|
|
?>
|