Project

General

Profile

« Previous | Next » 

Revision 687

Added by doc almost 17 years ago

added visualization of wrong/empty input fields, fixed bug with re-enter of admin password

View differences:

trunk/CHANGELOG
11 11
! = Update/Change
12 12

  
13 13
------------------------------------- 2.7.0 -------------------------------------
14
10-Feb-2008 Christian Sommer
15
!	added visualization of wrong/empty input fields
16
#	fixed a bug with re-enter admin password
14 17
09-Feb-2008 Christian Sommer
15 18
!	modified some colors and CSS definitions of pages, media and section interface
16 19
#	output_filter: fixed bug in regular expression (eats up characters in mailto links)
trunk/wb/install/stylesheet.css
12 12
form {
13 13
	margin: 0;
14 14
}
15

  
16
input:hover, input:focus, select:hover, select:focus, option:hover, option:focus {
17
	background: #FFFFE0;
18
}
19

  
20
.wrong {
21
	background-color: #FFDBDB;
22
}
23

  
15 24
.submit {
16 25
	border : solid 1px #CCCCCC;
17 26
	background: #E9ECEF;
trunk/wb/install/save.php
35 35
$session_rand = rand(1000,9999);
36 36

  
37 37
// Function to set error
38
function set_error($message) {
38
function set_error($message, $field_name = '') {
39 39
	global $_POST;
40 40
	if(isset($message) AND $message != '') {
41 41
		// Copy values entered into session so user doesn't have to re-enter everything
......
67 67
			$_SESSION['admin_username'] = $_POST['admin_username'];
68 68
			$_SESSION['admin_email'] = $_POST['admin_email'];
69 69
			$_SESSION['admin_password'] = $_POST['admin_password'];
70
			$_SESSION['admin_repassword'] = $_POST['admin_repassword'];
70 71
		}
71 72
		// Set the message
72 73
		$_SESSION['message'] = $message;
74
		// Set the element(s) to highlight
75
		if($field_name != '') {
76
			$_SESSION['ERROR_FIELD'] = $field_name;
77
		}
73 78
		// Specify that session support is enabled
74 79
		$_SESSION['session_support'] = '<font class="good">Enabled</font>';
75 80
		// Redirect to first page again and exit
......
139 144

  
140 145
// Check if user has entered the installation url
141 146
if(!isset($_POST['wb_url']) OR $_POST['wb_url'] == '') {
142
	set_error('Please enter an absolute URL');
147
	set_error('Please enter an absolute URL', 'wb_url');
143 148
} else {
144 149
	$wb_url = $_POST['wb_url'];
145 150
}
......
158 163
}
159 164
// Get the default time zone
160 165
if(!isset($_POST['default_timezone']) OR !is_numeric($_POST['default_timezone'])) {
161
	set_error('Please select a valid default timezone');
166
	set_error('Please select a valid default timezone', 'default_timezone');
162 167
} else {
163 168
	$default_timezone = $_POST['default_timezone']*60*60;
164 169
}
......
167 172
// Get the default language
168 173
$allowed_languages = array('CA', 'DA', 'DE', 'EN', 'ES', 'ET', 'FI', 'FR', 'HR', 'HU', 'IT', 'LV', 'NL', 'PT','SE', 'TR');
169 174
if(!isset($_POST['default_language']) OR !in_array($_POST['default_language'], $allowed_languages)) {
170
	set_error('Please select a valid default backend language');
175
	set_error('Please select a valid default backend language','default_language');
171 176
} else {
172 177
	$default_language = $_POST['default_language'];
173 178
	// make sure the selected language file exists in the language folder
174 179
	if(!file_exists('../languages/' .$default_language .'.php')) {
175
		set_error('The language file: \'' .$default_language .'.php\' is missing. Upload file to language folder or choose another language');
180
		set_error('The language file: \'' .$default_language .'.php\' is missing. Upload file to language folder or choose another language','default_language');
176 181
	}
177 182
}
178 183
// End default language details code
......
200 205
// Begin database details code
201 206
// Check if user has entered a database host
202 207
if(!isset($_POST['database_host']) OR $_POST['database_host'] == '') {
203
	set_error('Please enter a database host name');
208
	set_error('Please enter a database host name', 'database_host');
204 209
} else {
205 210
	$database_host = $_POST['database_host'];
206 211
}
207 212
// Check if user has entered a database username
208 213
if(!isset($_POST['database_username']) OR $_POST['database_username'] == '') {
209
	set_error('Please enter a database username');
214
	set_error('Please enter a database username','database_username');
210 215
} else {
211 216
	$database_username = $_POST['database_username'];
212 217
}
213 218
// Check if user has entered a database password
214 219
if(!isset($_POST['database_password'])) {
215
	set_error('Please enter a database password');
220
	set_error('Please enter a database password', 'database_password');
216 221
} else {
217 222
	$database_password = $_POST['database_password'];
218 223
}
219 224
// Check if user has entered a database name
220 225
if(!isset($_POST['database_name']) OR $_POST['database_name'] == '') {
221
	set_error('Please enter a database name');
226
	set_error('Please enter a database name', 'database_name');
222 227
} else {
223 228
	$database_name = $_POST['database_name'];
224 229
}
......
235 240
// Begin website title code
236 241
// Get website title
237 242
if(!isset($_POST['website_title']) OR $_POST['website_title'] == '') {
238
	set_error('Please enter a website title');
243
	set_error('Please enter a website title', 'website_title');
239 244
} else {
240 245
	$website_title = add_slashes($_POST['website_title']);
241 246
}
......
244 249
// Begin admin user details code
245 250
// Get admin username
246 251
if(!isset($_POST['admin_username']) OR $_POST['admin_username'] == '') {
247
	set_error('Please enter a username for the Administrator account');
252
	set_error('Please enter a username for the Administrator account','admin_username');
248 253
} else {
249 254
	$admin_username = $_POST['admin_username'];
250 255
}
251 256
// Get admin email and validate it
252 257
if(!isset($_POST['admin_email']) OR $_POST['admin_email'] == '') {
253
	set_error('Please enter an email for the Administrator account');
258
	set_error('Please enter an email for the Administrator account','admin_email');
254 259
} else {
255 260
	if(eregi("^([0-9a-zA-Z]+[-._+&])*[0-9a-zA-Z]+@([-0-9a-zA-Z]+[.])+[a-zA-Z]{2,6}$", $_POST['admin_email'])) {
256 261
		$admin_email = $_POST['admin_email'];
257 262
	} else {
258
		set_error('Please enter a valid email address for the Administrator account');
263
		set_error('Please enter a valid email address for the Administrator account','admin_email');
259 264
	}
260 265
}
261 266
// Get the two admin passwords entered, and check that they match
262 267
if(!isset($_POST['admin_password']) OR $_POST['admin_password'] == '') {
263
	set_error('Please enter a password for the Administrator account');
268
	set_error('Please enter a password for the Administrator account','admin_password');
264 269
} else {
265 270
	$admin_password = $_POST['admin_password'];
266 271
}
267 272
if(!isset($_POST['admin_repassword']) OR $_POST['admin_repassword'] == '') {
268
	set_error('Please make sure you re-enter the password for the Administrator account');
273
	set_error('Please make sure you re-enter the password for the Administrator account','admin_repassword');
269 274
} else {
270 275
	$admin_repassword = $_POST['admin_repassword'];
271 276
}
272 277
if($admin_password != $admin_repassword) {
273
	set_error('Sorry, the two Administrator account passwords you entered do not match');
278
	set_error('Sorry, the two Administrator account passwords you entered do not match','admin_repassword');
274 279
}
275 280
// End admin user details code
276 281

  
trunk/wb/install/index.php
30 30
	define('SESSION_STARTED', true);
31 31
}
32 32

  
33
// Function to highlight input fields which contain wrong/missing data
34
function field_error($field_name='') {
35
	if(!defined('SESSION_STARTED') || $field_name == '') return;
36
	if(isset($_SESSION['ERROR_FIELD']) && $_SESSION['ERROR_FIELD'] == $field_name) {
37
		return ' class="wrong"';
38
	}
39
}
40

  
33 41
// Check if the page has been reloaded
34 42
if(!isset($_GET['sessions_checked']) OR $_GET['sessions_checked'] != 'true') {
35 43
	// Set session variable
......
179 187
				$guessed_url = 'http://'.$_SERVER["SERVER_NAME"].$_SERVER["SCRIPT_NAME"];
180 188
				$guessed_url = rtrim(dirname($guessed_url), 'install');
181 189
				?>
182
				<input type="text" tabindex="1" name="wb_url" style="width: 99%;" value="<?php if(isset($_SESSION['wb_url'])) { echo $_SESSION['wb_url']; } else { echo $guessed_url; } ?>" />
190
				<input <?php echo field_error('wb_url');?> type="text" tabindex="1" name="wb_url" style="width: 99%;" value="<?php if(isset($_SESSION['wb_url'])) { echo $_SESSION['wb_url']; } else { echo $guessed_url; } ?>" />
183 191
			</td>
184 192
		</tr>
185 193
		<tr>
......
187 195
				Default Timezone:
188 196
			</td>
189 197
			<td>
190
				<select tabindex="3" name="default_timezone" style="width: 100%;">
198
				<select <?php echo field_error('default_timezone');?> tabindex="3" name="default_timezone" style="width: 100%;">
191 199
					<?php
192 200
					$TIMEZONES['-12'] = 'GMT - 12 Hours';
193 201
					$TIMEZONES['-11'] = 'GMT -11 Hours';
......
235 243
				Default Language:
236 244
			</td>
237 245
			<td>
238
				<select tabindex="3" name="default_language" style="width: 100%;">
246
				<select <?php echo field_error('default_language');?> tabindex="3" name="default_language" style="width: 100%;">
239 247
					<?php
240 248
					$DEFAULT_LANGUAGE = array(
241 249
						'CA'=>'Catalan', 'DA'=>'Danish', 'DE'=>'Deutsch', 'EN'=>'English',
......
287 295
		<tr>
288 296
			<td width="120" style="color: #666666;">Host Name:</td>
289 297
			<td width="230">
290
				<input type="text" tabindex="7" name="database_host" style="width: 98%;" value="<?php if(isset($_SESSION['database_host'])) { echo $_SESSION['database_host']; } else { echo 'localhost'; } ?>" />
298
				<input <?php echo field_error('database_host');?> type="text" tabindex="7" name="database_host" style="width: 98%;" value="<?php if(isset($_SESSION['database_host'])) { echo $_SESSION['database_host']; } else { echo 'localhost'; } ?>" />
291 299
			</td>
292 300
			<td width="7">&nbsp;</td>
293 301
			<td width="70" style="color: #666666;">Username:</td>
294 302
			<td>
295
				<input type="text" tabindex="9" name="database_username" style="width: 98%;" value="<?php if(isset($_SESSION['database_username'])) { echo $_SESSION['database_username']; } else { echo 'root'; } ?>" />
303
				<input <?php echo field_error('database_username');?> type="text" tabindex="9" name="database_username" style="width: 98%;" value="<?php if(isset($_SESSION['database_username'])) { echo $_SESSION['database_username']; } else { echo 'root'; } ?>" />
296 304
			</td>
297 305
		</tr>
298 306
		<tr>
299 307
			<td style="color: #666666;">Database Name:</td>
300 308
			<td>
301
				<input type="text" tabindex="8" name="database_name" style="width: 98%;" value="<?php if(isset($_SESSION['database_name'])) { echo $_SESSION['database_name']; } else { echo 'wb'; } ?>" />
309
				<input <?php echo field_error('database_name');?> type="text" tabindex="8" name="database_name" style="width: 98%;" value="<?php if(isset($_SESSION['database_name'])) { echo $_SESSION['database_name']; } else { echo 'wb'; } ?>" />
302 310
			</td>
303 311
			<td>&nbsp;</td>
304 312
			<td style="color: #666666;">Password:</td>
......
325 333
		<tr>
326 334
			<td style="color: #666666;" colspan="1">Website Title:</td>
327 335
			<td colspan="4">
328
				<input type="text" tabindex="13" name="website_title" style="width: 99%;" value="<?php if(isset($_SESSION['website_title'])) { echo $_SESSION['website_title']; } ?>" />
336
				<input <?php echo field_error('website_title');?> type="text" tabindex="13" name="website_title" style="width: 99%;" value="<?php if(isset($_SESSION['website_title'])) { echo $_SESSION['website_title']; } ?>" />
329 337
			</td>
330 338
		</tr>
331 339
		<tr>
......
334 342
		<tr>
335 343
			<td style="color: #666666;">Username:</td>
336 344
			<td>
337
				<input type="text" tabindex="14" name="admin_username" style="width: 98%;" value="<?php if(isset($_SESSION['admin_username'])) { echo $_SESSION['admin_username']; } else { echo 'admin'; } ?>" />
345
				<input <?php echo field_error('admin_username');?> type="text" tabindex="14" name="admin_username" style="width: 98%;" value="<?php if(isset($_SESSION['admin_username'])) { echo $_SESSION['admin_username']; } else { echo 'admin'; } ?>" />
338 346
			</td>
339 347
			<td>&nbsp;</td>
340 348
			<td style="color: #666666;">Password:</td>
341 349
			<td>
342
				<input type="password" tabindex="16" name="admin_password" style="width: 98%;"<?php if(isset($_SESSION['admin_password'])) { echo ' value = "'.$_SESSION['admin_password'].'"'; } ?> />
350
				<input <?php echo field_error('admin_password');?> type="password" tabindex="16" name="admin_password" style="width: 98%;"<?php if(isset($_SESSION['admin_password'])) { echo ' value = "'.$_SESSION['admin_password'].'"'; } ?> />
343 351
			</td>
344 352
		</tr>
345 353
		<tr>
346 354
			<td style="color: #666666;">Email:</td>
347 355
			<td>
348
				<input type="text" tabindex="15" name="admin_email" style="width: 98%;"<?php if(isset($_SESSION['admin_email'])) { echo ' value = "'.$_SESSION['admin_email'].'"'; } ?> />
356
				<input <?php echo field_error('admin_email');?> type="text" tabindex="15" name="admin_email" style="width: 98%;"<?php if(isset($_SESSION['admin_email'])) { echo ' value = "'.$_SESSION['admin_email'].'"'; } ?> />
349 357
			</td>
350 358
			<td>&nbsp;</td>
351 359
			<td style="color: #666666;">Re-Password:</td>
352 360
			<td>
353
				<input type="password" tabindex="17" name="admin_repassword" style="width: 98%;"<?php if(isset($_SESSION['admin_password'])) { echo ' value = "'.$_SESSION['admin_password'].'"'; } ?> />
361
				<input <?php echo field_error('admin_repassword');?> type="password" tabindex="17" name="admin_repassword" style="width: 98%;"<?php if(isset($_SESSION['admin_repassword'])) { echo ' value = "'.$_SESSION['admin_repassword'].'"'; } ?> />
354 362
			</td>
355 363
		</tr>
356 364
		<tr>

Also available in: Unified diff