Project

General

Profile

« Previous | Next » 

Revision 275

Added by stefan almost 19 years ago

Replace 'admin' by 'wb' in all account pages. Moved print_success and print_error code to class.wb.php. Added correct parameters to these functions in account pages.

View differences:

trunk/wb/account/password.php
1 1
<?php
2 2

  
3
// $Id: password.php,v 1.2 2005/03/28 11:58:03 rdjurovich Exp $
3
// $Id$
4 4

  
5 5
/*
6 6

  
......
37 37

  
38 38
// Get existing password
39 39
$database = new database();
40
$query = "SELECT user_id FROM ".TABLE_PREFIX."users WHERE user_id = '".$admin->get_user_id()."' AND password = '".md5($current_password)."'";
40
$query = "SELECT user_id FROM ".TABLE_PREFIX."users WHERE user_id = '".$wb->get_user_id()."' AND password = '".md5($current_password)."'";
41 41
$results = $database->query($query);
42 42

  
43 43
// Validate values
44 44
if($results->numRows() == 0) {
45
	$admin->print_error($MESSAGE['PREFERENCES']['CURRENT_PASSWORD_INCORRECT'], $js_back);
45
	$wb->print_error($MESSAGE['PREFERENCES']['CURRENT_PASSWORD_INCORRECT'], $js_back, false);
46 46
}
47 47
if(strlen($new_password) < 3) {
48
	$admin->print_error($MESSAGE['USERS']['PASSWORD_TOO_SHORT'], $js_back);
48
	$wb->print_error($MESSAGE['USERS']['PASSWORD_TOO_SHORT'], $js_back, false);
49 49
}
50 50
if($new_password != $new_password2) {
51
	$admin->print_error($MESSAGE['USERS']['PASSWORD_MISMATCH'], $js_back);
51
	$wb->print_error($MESSAGE['USERS']['PASSWORD_MISMATCH'], $js_back, false);
52 52
}
53 53

  
54 54
// MD5 the password
......
56 56

  
57 57
// Update the database
58 58
$database = new database();
59
$query = "UPDATE ".TABLE_PREFIX."users SET password = '$md5_password' WHERE user_id = '".$admin->get_user_id()."'";
59
$query = "UPDATE ".TABLE_PREFIX."users SET password = '$md5_password' WHERE user_id = '".$wb->get_user_id()."'";
60 60
$database->query($query);
61 61
if($database->is_error()) {
62
	$admin->print_error($database->get_error);
62
	$wb->print_error($database->get_error, 'index.php', false);
63 63
} else {
64
	$admin->print_success($MESSAGE['PREFERENCES']['PASSWORD_CHANGED'], WB_URL.'/account/preferences'.PAGE_EXTENSION);
64
	$wb->print_success($MESSAGE['PREFERENCES']['PASSWORD_CHANGED'], WB_URL.'/account/preferences'.PAGE_EXTENSION);
65 65
}
66 66

  
67 67

  
trunk/wb/account/preferences_form.php
35 35
<input type="hidden" name="user_id" value="{USER_ID}" />
36 36

  
37 37
<table cellpadding="5" cellspacing="0" border="0" width="97%">
38
<tr>
39 38
	<td width="140"><?php echo $TEXT['DISPLAY_NAME']; ?>:</td>
40 39
	<td class="value_input">
41
		<input type="text" name="display_name" style="width: 380px;" maxlength="255" value="<?php echo $admin->get_display_name(); ?>" />
40
		<input type="text" name="display_name" style="width: 380px;" maxlength="255" value="<?php echo $wb->get_display_name(); ?>" />
42 41
	</td>
43 42
</tr>
44 43
<tr>
......
80 79
			// Insert default timezone values
81 80
			require_once(ADMIN_PATH.'/interface/timezones.php');
82 81
			foreach($TIMEZONES AS $hour_offset => $title) {
83
				if($admin->get_timezone() == $hour_offset*60*60) {
82
				if($wb->get_timezone() == $hour_offset*60*60) {
84 83
					?>
85 84
					<option value="<?php echo $hour_offset; ?>" selected><?php echo $title; ?></option>
86 85
					<?php
......
179 178
<tr>
180 179
	<td><?php echo $TEXT['EMAIL']; ?>:</td>
181 180
	<td class="value_input">
182
		<input type="text" name="email" style="width: 380px;" maxlength="255" value="<?php echo $admin->get_email(); ?>" />
181
		<input type="text" name="email" style="width: 380px;" maxlength="255" value="<?php echo $wb->get_email(); ?>" />
183 182
	</td>
184 183
</tr>
185 184
<tr>
trunk/wb/account/details.php
28 28
}
29 29

  
30 30
// Get entered values
31
$display_name = $admin->get_post('display_name');
32
$language = $admin->get_post('language');
33
$timezone = $admin->get_post('timezone')*60*60;
34
$date_format = $admin->get_post('date_format');
35
$time_format = $admin->get_post('time_format');
31
$display_name = $wb->get_post('display_name');
32
$language = $wb->get_post('language');
33
$timezone = $wb->get_post('timezone')*60*60;
34
$date_format = $wb->get_post('date_format');
35
$time_format = $wb->get_post('time_format');
36 36

  
37 37
// Create a javascript back link
38 38
$js_back = "javascript: history.go(-1);";
39 39

  
40 40
// Update the database
41 41
$database = new database();
42
$query = "UPDATE ".TABLE_PREFIX."users SET display_name = '$display_name', language = '$language', timezone = '$timezone', date_format = '$date_format', time_format = '$time_format' WHERE user_id = '".$admin->get_user_id()."'";
42
$query = "UPDATE ".TABLE_PREFIX."users SET display_name = '$display_name', language = '$language', timezone = '$timezone', date_format = '$date_format', time_format = '$time_format' WHERE user_id = '".$wb->get_user_id()."'";
43 43
$database->query($query);
44 44
if($database->is_error()) {
45
	$admin->print_error($database->get_error);
45
	$wb->print_error($database->get_error,'index.php',false);
46 46
} else {
47
	$admin->print_success($MESSAGE['PREFERENCES']['DETAILS_SAVED'], WB_URL.'/account/preferences'.PAGE_EXTENSION);
47
	$wb->print_success($MESSAGE['PREFERENCES']['DETAILS_SAVED'], WB_URL.'/account/preferences'.PAGE_EXTENSION);
48 48
	$_SESSION['DISPLAY_NAME'] = $display_name;
49 49
	$_SESSION['LANGUAGE'] = $language;
50 50
	$_SESSION['TIMEZONE'] = $timezone;
trunk/wb/account/email.php
1 1
<?php
2 2

  
3
// $Id: email.php,v 1.2 2005/03/28 11:58:03 rdjurovich Exp $
3
// $Id$
4 4

  
5 5
/*
6 6

  
......
28 28
}
29 29

  
30 30
// Get the values entered
31
$current_password = $admin->get_post('current_password');
32
$email = $admin->get_post('email');
31
$current_password = $wb->get_post('current_password');
32
$email = $wb->get_post('email');
33 33

  
34 34
// Create a javascript back link
35 35
$js_back = "javascript: history.go(-1);";
36 36

  
37 37
// Get existing password
38 38
$database = new database();
39
$query = "SELECT user_id FROM ".TABLE_PREFIX."users WHERE user_id = '".$admin->get_user_id()."' AND password = '".md5($current_password)."'";
39
$query = "SELECT user_id FROM ".TABLE_PREFIX."users WHERE user_id = '".$wb->get_user_id()."' AND password = '".md5($current_password)."'";
40 40
$results = $database->query($query);
41 41

  
42 42
// Validate values
43 43
if($results->numRows() == 0) {
44
	$admin->print_error($MESSAGE['PREFERENCES']['OLD_PASSWORD_INCORRECT'], $js_back);
44
	$wb->print_error($MESSAGE['PREFERENCES']['OLD_PASSWORD_INCORRECT'], $js_back, false);
45 45
}
46 46
// Validate values
47
if(!$admin->validate_email($email)) {
48
	$admin->print_error($MESSAGE['USERS']['INVALID_EMAIL'], $js_back);
47
if(!$wb->validate_email($email)) {
48
	$wb->print_error($MESSAGE['USERS']['INVALID_EMAIL'], $js_back, false);
49 49
}
50 50

  
51 51
// Update the database
52 52
$database = new database();
53
$query = "UPDATE ".TABLE_PREFIX."users SET email = '$email' WHERE user_id = '".$admin->get_user_id()."' AND password = '".md5($current_password)."'";
53
$query = "UPDATE ".TABLE_PREFIX."users SET email = '$email' WHERE user_id = '".$wb->get_user_id()."' AND password = '".md5($current_password)."'";
54 54
$database->query($query);
55 55
if($database->is_error()) {
56
	$admin->print_error($database->get_error);
56
	$wb->print_error($database->get_error,'index.php', false);
57 57
} else {
58
	$admin->print_success($MESSAGE['PREFERENCES']['EMAIL_UPDATED'], WB_URL.'/account/preferences'.PAGE_EXTENSION);
58
	$wb->print_success($MESSAGE['PREFERENCES']['EMAIL_UPDATED'], WB_URL.'/account/preferences'.PAGE_EXTENSION);
59 59
	$_SESSION['EMAIL'] = $email;
60 60
}
61 61

  
trunk/wb/account/signup2.php
27 27
	header('Location: ../pages/index.php');
28 28
}
29 29

  
30
require_once(WB_PATH.'/framework/class.admin.php');
31
$admin = new admin('Start', 'start', false, false);
30
require_once(WB_PATH.'/framework/class.wb.php');
31
$wb = new wb('Start', 'start', false, false);
32 32

  
33 33
// Create new database object
34 34
$database = new database();
......
36 36
// Get details entered
37 37
$group_id = FRONTEND_SIGNUP;
38 38
$active = 1;
39
$username = strtolower($admin->get_post('username'));
40
$display_name = $admin->get_post('display_name');
41
$email = $admin->get_post('email');
39
$username = strtolower($wb->get_post('username'));
40
$display_name = $wb->get_post('display_name');
41
$email = $wb->get_post('email');
42 42

  
43 43
// Create a javascript back link
44 44
$js_back = "javascript: history.go(-1);";
45 45

  
46 46
// Check values
47 47
if($group_id == "") {
48
	$admin->print_error($MESSAGE['USERS']['NO_GROUP'], $js_back);
48
	$wb->print_error($MESSAGE['USERS']['NO_GROUP'], $js_back, false);
49 49
}
50 50
if(strlen($username) < 3) {
51
	$admin->print_error($MESSAGE['USERS']['USERNAME_TOO_SHORT'], $js_back);
51
	$wb->print_error($MESSAGE['USERS']['USERNAME_TOO_SHORT'], $js_back, false);
52 52
}
53 53
if($email != "") {
54
	if($admin->validate_email($email) == false) {
55
		$admin->print_error($MESSAGE['USERS']['INVALID_EMAIL'], $js_back);
54
	if($wb->validate_email($email) == false) {
55
		$wb->print_error($MESSAGE['USERS']['INVALID_EMAIL'], $js_back, false);
56 56
	}
57 57
} else {
58
	$admin->print_error($MESSAGE['SIGNUP']['NO_EMAIL'], $js_back);
58
	$wb->print_error($MESSAGE['SIGNUP']['NO_EMAIL'], $js_back, false);
59 59
}
60 60
// Captcha
61 61
if(extension_loaded('gd') AND function_exists('imageCreateFromJpeg') AND CAPTCHA_VERIFICATION) { /* Make's sure GD library is installed */
62 62
	if(isset($_POST['captcha']) AND $_POST['captcha'] != ''){
63 63
		// Check for a mismatch
64 64
		if(!isset($_POST['captcha']) OR !isset($_SESSION['captcha']) OR $_POST['captcha'] != $_SESSION['captcha']) {
65
			$admin->print_error($MESSAGE['MOD_FORM']['INCORRECT_CAPTCHA'], $js_back);
65
			$wb->print_error($MESSAGE['MOD_FORM']['INCORRECT_CAPTCHA'], $js_back, false);
66 66
		}
67 67
	} else {
68
		$admin->print_error($MESSAGE['MOD_FORM']['INCORRECT_CAPTCHA'], $js_back);
68
		$wb->print_error($MESSAGE['MOD_FORM']['INCORRECT_CAPTCHA'], $js_back, false);
69 69
	}
70 70
}
71 71
if(isset($_SESSION['catpcha'])) { unset($_SESSION['captcha']); }
......
86 86
// Check if username already exists
87 87
$results = $database->query("SELECT user_id FROM ".TABLE_PREFIX."users WHERE username = '$username'");
88 88
if($results->numRows() > 0) {
89
	$admin->print_error($MESSAGE['USERS']['USERNAME_TAKEN'], $js_back);
89
	$wb->print_error($MESSAGE['USERS']['USERNAME_TAKEN'], $js_back, false);
90 90
}
91 91

  
92 92
// Check if the email already exists
93 93
$results = $database->query("SELECT user_id FROM ".TABLE_PREFIX."users WHERE email = '".$wb->add_slashes($_POST['email'])."'");
94 94
if($results->numRows() > 0) {
95 95
	if(isset($MESSAGE['USERS']['EMAIL_TAKEN'])) {
96
		$admin->print_error($MESSAGE['USERS']['EMAIL_TAKEN'], $js_back);
96
		$wb->print_error($MESSAGE['USERS']['EMAIL_TAKEN'], $js_back, false);
97 97
	} else {
98
		$admin->print_error($MESSAGE['USERS']['INVALID_EMAIL'], $js_back);
98
		$wb->print_error($MESSAGE['USERS']['INVALID_EMAIL'], $js_back, false);
99 99
	}
100 100
}
101 101

  
......
126 126

  
127 127
	// Try sending the email
128 128
	if(mail($mail_to, $mail_subject, $mail_message, 'From: '.SERVER_EMAIL)) {
129
		$admin->print_success($MESSAGE['FORGOT_PASS']['PASSWORD_RESET'], WB_URL.'/account/login'.PAGE_EXTENSION);
129
		$wb->print_success($MESSAGE['FORGOT_PASS']['PASSWORD_RESET'], WB_URL.'/account/login'.PAGE_EXTENSION);
130 130
		$display_form = false;
131 131
	} else {
132
		$admin->print_error($MESSAGE['FORGOT_PASS']['CANNOT_EMAIL'], $js_back);
132
		$wb->print_error($MESSAGE['FORGOT_PASS']['CANNOT_EMAIL'], $js_back, false);
133 133
	}
134 134
}
135 135

  
trunk/wb/framework/class.admin.php
145 145
		$footer_template->pparse('output', 'page');
146 146
	}
147 147
	
148
	// Print a success message which then automatically redirects the user to another page
149
	function print_success($message, $redirect = 'index.php') {
150
		global $TEXT;
151
		$success_template = new Template(ADMIN_PATH.'/interface');
152
		$success_template->set_file('page', 'success.html');
153
		$success_template->set_block('page', 'main_block', 'main');
154
		$success_template->set_var('MESSAGE', $message);
155
		$success_template->set_var('REDIRECT', $redirect);
156
		$success_template->set_var('NEXT', $TEXT['NEXT']);
157
		$success_template->parse('main', 'main_block', false);
158
		$success_template->pparse('output', 'page');
159
	}
160
	
161
	// Print a error message
162
	function print_error($message, $link = 'index.php', $auto_footer = true) {
163
		global $TEXT;
164
		$success_template = new Template(ADMIN_PATH.'/interface');
165
		$success_template->set_file('page', 'error.html');
166
		$success_template->set_block('page', 'main_block', 'main');
167
		$success_template->set_var('MESSAGE', $message);
168
		$success_template->set_var('LINK', $link);
169
		$success_template->set_var('BACK', $TEXT['BACK']);
170
		$success_template->parse('main', 'main_block', false);
171
		$success_template->pparse('output', 'page');
172
		if($auto_footer == true) {
173
			$this->print_footer();
174
		}
175
		exit();
176
	}
177

  
178 148
	// Return a system permission
179 149
	function get_permission($name, $type = 'system') {
180 150
		// Append to permission type
trunk/wb/framework/class.wb.php
31 31

  
32 32
*/
33 33

  
34
// Include PHPLIB template class
35
require_once(WB_PATH."/include/phplib/template.inc");
36

  
34 37
require_once(WB_PATH.'/framework/class.database.php');
35 38

  
36 39
class wb
......
193 196
		}
194 197
	}
195 198

  
199
	// Print a success message which then automatically redirects the user to another page
200
	function print_success($message, $redirect = 'index.php') {
201
		global $TEXT;
202
		$success_template = new Template(ADMIN_PATH.'/interface');
203
		$success_template->set_file('page', 'success.html');
204
		$success_template->set_block('page', 'main_block', 'main');
205
		$success_template->set_var('MESSAGE', $message);
206
		$success_template->set_var('REDIRECT', $redirect);
207
		$success_template->set_var('NEXT', $TEXT['NEXT']);
208
		$success_template->parse('main', 'main_block', false);
209
		$success_template->pparse('output', 'page');
210
	}
196 211
	
212
	// Print an error message
213
	function print_error($message, $link = 'index.php', $auto_footer = true) {
214
		global $TEXT;
215
		$success_template = new Template(ADMIN_PATH.'/interface');
216
		$success_template->set_file('page', 'error.html');
217
		$success_template->set_block('page', 'main_block', 'main');
218
		$success_template->set_var('MESSAGE', $message);
219
		$success_template->set_var('LINK', $link);
220
		$success_template->set_var('BACK', $TEXT['BACK']);
221
		$success_template->parse('main', 'main_block', false);
222
		$success_template->pparse('output', 'page');
223
		if($auto_footer == true) {
224
			$this->print_footer();
225
		}
226
		exit();
227
	}
228

  
197 229
}
198 230
?>

Also available in: Unified diff