Project

General

Profile

1
<?php
2
/*
3
*
4
*                       About WebsiteBaker
5
*
6
* Website Baker is a PHP-based Content Management System (CMS)
7
* designed with one goal in mind: to enable its users to produce websites
8
* with ease.
9
*
10
*                       LICENSE INFORMATION
11
*
12
* WebsiteBaker is free software; you can redistribute it and/or
13
* modify it under the terms of the GNU General Public License
14
* as published by the Free Software Foundation; either version 2
15
* of the License, or (at your option) any later version.
16
*
17
* WebsiteBaker is distributed in the hope that it will be useful,
18
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20
* See the GNU General Public License for more details.
21
*
22
* You should have received a copy of the GNU General Public License
23
* along with this program; if not, write to the Free Software
24
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
*
26
*                   WebsiteBaker Extra Information
27
*
28
*
29
*/
30
/**
31
 *
32
 * @category        admin
33
 * @package         settings
34
 * @author          Ryan Djurovich
35
 * @copyright       2004-2009, Ryan Djurovich
36
 * @copyright       2009-2010, Website Baker Org. e.V.
37
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/settings/save.php $
38
 * @author          Ryan Djurovich
39
 * @copyright       2004-2009, Ryan Djurovich
40
 *
41
 * @author          WebsiteBaker Project
42
 * @link			http://www.websitebaker2.org/
43
 * @copyright       2009-2010, Website Baker Org. e.V.
44
 * @link			http://start.websitebaker2.org/impressum-datenschutz.php
45
 * @license         http://www.gnu.org/licenses/gpl.html
46
 * @version         $Id: save.php 1255 2010-01-21 01:14:59Z Luisehahne $
47
 * @platform        WebsiteBaker 2.8.x
48
 * @requirements    PHP 4.3.4 and higher
49
 * @lastmodified    $Date: 2010-01-21 02:14:59 +0100 (Thu, 21 Jan 2010) $
50
 *
51
 */
52

    
53
// prevent this file from being accessed directly in the browser (would set all entries in DB settings table to '')
54
if(!isset($_POST['default_language']) || $_POST['default_language'] == '') die(header('Location: index.php'));
55

    
56
// Find out if the user was view advanced options or not
57
if($_POST['advanced'] == 'yes' ? $advanced = '?advanced=yes' : $advanced = '');
58

    
59
// Print admin header
60
require('../../config.php');
61
require_once(WB_PATH.'/framework/class.admin.php');
62
if($advanced == '') {
63
	$admin = new admin('Settings', 'settings_basic');
64
	$_POST['database_password'] = DB_PASSWORD;
65
} else {
66
	$admin = new admin('Settings', 'settings_advanced');
67
}
68

    
69
// Create a javascript back link
70
$js_back = "javascript: history.go(-1);";
71

    
72
// Ensure that the specified default email is formally valid
73
if(isset($_POST['server_email']))
74
{
75
	$_POST['server_email'] = strip_tags($_POST['server_email']);
76
	if(!eregi("^([0-9a-zA-Z]+[-._+&])*[0-9a-zA-Z]+@([-0-9a-zA-Z]+[.])+[a-zA-Z]{2,6}$", $_POST['server_email'])) {
77
		$admin->print_error($MESSAGE['USERS']['INVALID_EMAIL'].
78
			'<br /><strong>Email: '.htmlentities($_POST['server_email']).'</strong>', $js_back);
79
	}
80
}
81

    
82
// Work-out file mode
83
if($advanced == '')
84
{
85
	// Check if should be set to 777 or left alone
86
	if(isset($_POST['world_writeable']) AND $_POST['world_writeable'] == 'true')
87
    {
88
		$file_mode = '0777';
89
		$dir_mode = '0777';
90
	} else {
91
		$file_mode = STRING_FILE_MODE;
92
		$dir_mode = STRING_DIR_MODE;
93
	}
94
} else {
95
	// Work-out the octal value for file mode
96
	$u = 0;
97
	if(isset($_POST['file_u_r']) AND $_POST['file_u_r'] == 'true') {
98
		$u = $u+4;
99
	}
100
	if(isset($_POST['file_u_w']) AND $_POST['file_u_w'] == 'true') {
101
		$u = $u+2;
102
	}
103
	if(isset($_POST['file_u_e']) AND $_POST['file_u_e'] == 'true') {
104
		$u = $u+1;
105
	}
106
	$g = 0;
107
	if(isset($_POST['file_g_r']) AND $_POST['file_g_r'] == 'true') {
108
		$g = $g+4;
109
	}
110
	if(isset($_POST['file_g_w']) AND $_POST['file_g_w'] == 'true') {
111
		$g = $g+2;
112
	}
113
	if(isset($_POST['file_g_e']) AND $_POST['file_g_e'] == 'true') {
114
		$g = $g+1;
115
	}
116
	$o = 0;
117
	if(isset($_POST['file_o_r']) AND $_POST['file_o_r'] == 'true') {
118
		$o = $o+4;
119
	}
120
	if(isset($_POST['file_o_w']) AND $_POST['file_o_w'] == 'true') {
121
		$o = $o+2;
122
	}
123
	if(isset($_POST['file_o_e']) AND $_POST['file_o_e'] == 'true') {
124
		$o = $o+1;
125
	}
126
	$file_mode = "0".$u.$g.$o;
127
	// Work-out the octal value for dir mode
128
	$u = 0;
129
	if(isset($_POST['dir_u_r']) AND $_POST['dir_u_r'] == 'true') {
130
		$u = $u+4;
131
	}
132
	if(isset($_POST['dir_u_w']) AND $_POST['dir_u_w'] == 'true') {
133
		$u = $u+2;
134
	}
135
	if(isset($_POST['dir_u_e']) AND $_POST['dir_u_e'] == 'true') {
136
		$u = $u+1;
137
	}
138
	$g = 0;
139
	if(isset($_POST['dir_g_r']) AND $_POST['dir_g_r'] == 'true') {
140
		$g = $g+4;
141
	}
142
	if(isset($_POST['dir_g_w']) AND $_POST['dir_g_w'] == 'true') {
143
		$g = $g+2;
144
	}
145
	if(isset($_POST['dir_g_e']) AND $_POST['dir_g_e'] == 'true') {
146
		$g = $g+1;
147
	}
148
	$o = 0;
149
	if(isset($_POST['dir_o_r']) AND $_POST['dir_o_r'] == 'true') {
150
		$o = $o+4;
151
	}
152
	if(isset($_POST['dir_o_w']) AND $_POST['dir_o_w'] == 'true') {
153
		$o = $o+2;
154
	}
155
	if(isset($_POST['dir_o_e']) AND $_POST['dir_o_e'] == 'true') {
156
		$o = $o+1;
157
	}
158
	$dir_mode = "0".$u.$g.$o;
159
}
160

    
161
// Create new database object
162
/*$database = new database(); */
163

    
164
// Query current settings in the db, then loop through them and update the db with the new value
165
$query = "SELECT name FROM ".TABLE_PREFIX."settings";
166
$results = $database->query($query);
167
while($setting = $results->fetchRow())
168
{
169
	$setting_name = $setting['name'];
170
	$value = $admin->get_post($setting_name);
171
	if ($setting_name!='wb_version')
172
    {
173
		$allow_tags_in_fields = array('website_header', 'website_footer','wbmailer_smtp_password');
174
		if(!in_array($setting_name, $allow_tags_in_fields)) {
175
			$value = strip_tags($value);
176
		}
177
		switch ($setting_name) {
178
			case 'default_timezone':
179
				$value=$value*60*60;
180
				break;
181
			case 'string_dir_mode':
182
				$value=$dir_mode;
183
				break;
184
			case 'string_file_mode':
185
				$value=$file_mode;
186
				break;
187
			case 'pages_directory':
188
				if(trim($value)=='/') $value='';
189
				break;
190
		}
191
		$value = $admin->add_slashes($value);
192
		$database->query("UPDATE ".TABLE_PREFIX."settings SET value = '$value' WHERE name = '$setting_name'");
193
	}
194
}
195

    
196
// Query current search settings in the db, then loop through them and update the db with the new value
197
$query = "SELECT name, value FROM ".TABLE_PREFIX."search WHERE extra = ''";
198
$results = $database->query($query);
199
while($search_setting = $results->fetchRow())
200
{
201
	$old_value = $search_setting['value'];
202
	$setting_name = $search_setting['name'];
203
	$post_name = 'search_'.$search_setting['name'];
204
    // hold old value if post is empty
205
    // check search template
206
    $value = ( ($admin->get_post($post_name) == '') AND ($setting_name != 'template') ) ? $old_value : $admin->get_post($post_name);
207

    
208
	$value = $admin->add_slashes($value);
209
	$database->query("UPDATE ".TABLE_PREFIX."search SET value = '$value' WHERE name = '$setting_name'");
210
}
211

    
212
// Check if there was an error updating the db
213
if($database->is_error()) {
214
	$admin->print_error($database->get_error, ADMIN_URL.'/settings/index.php'.$advanced);
215
	$admin->print_footer();
216
	exit();
217
}
218

    
219
$admin->print_success($MESSAGE['SETTINGS']['SAVED'], ADMIN_URL.'/settings/index.php'.$advanced);
220
$admin->print_footer();
221

    
222
?>
(2-2/3)