Project

General

Profile

« Previous | Next » 

Revision 1347

Added by Dietmar about 14 years ago

fix Droplet LoginBox fronend_signup (tks to Maverik)
fix save user e-mail,

View differences:

branches/2.8.x/CHANGELOG
11 11
! = Update/Change
12 12

  
13 13
------------------------------------- 2.8.1 -------------------------------------
14
23 Nov-2010 Dietmar Woellbrink (Luisehahne)
15
# fix Droplet LoginBox fronend_signup (tks to Maverik)
16
# fix save user e-mail,
14 17
12-May-2010 Dietmar Woellbrink (Luisehahne)
15 18
#	Ticket #999 wrong sql statement in admin/pages/index.php (Tks to Lucutus)
16 19
12-May-2010 Dietmar Woellbrink (Luisehahne)
branches/2.8.x/wb/admin/interface/version.php
1
<?php

2
/*

3
 * 						About WebsiteBaker

4
 *

5
 * Website Baker is a PHP-based Content Management System (CMS)

6
 * designed with one goal in mind: to enable its users to produce websites

7
 * with ease.

8
 *

9
 * 						LICENSE INFORMATION

10
 *

11
 * WebsiteBaker is free software; you can redistribute it and/or

12
 * modify it under the terms of the GNU General Public License

13
 * as published by the Free Software Foundation; either version 2

14
 * of the License, or (at your option) any later version.

15
 *

16
 * WebsiteBaker is distributed in the hope that it will be useful,

17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of

18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

19
 * See the GNU General Public License for more details.

20
 *

21
 * You should have received a copy of the GNU General Public License

22
 * along with this program; if not, write to the Free Software

23
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

24
 *

25
 * 				WebsiteBaker Extra Information

26
 *

27
 * This file is where the WB release version is stored.

28
 *

29
 */

30
/**

31
 *

32
 * @category     	admin

33
 * @package      	interface

34
 * @author          WebsiteBaker Project

35
 * @copyright       2004-2009, Ryan Djurovich

36
 * @copyright       2009-2010, Website Baker Org. e.V.

37
 * @link			http://www.websitebaker2.org/

38
 * @license         http://www.gnu.org/licenses/gpl.html

39
 * @platform        WebsiteBaker 2.8.x

40
 * @requirements    PHP 4.3.4 and higher

41
 * @revision     	$Revision$

42
 * @version      	$Id$

43
 * @filesource		$HeadURL$

44
 * @lastmodified    $Date$

45
 * 

46
 */

47

  
48
if(!defined('WB_URL')) {

49
	header('Location: ../index.php');

50
	exit(0);

51
}

52

  
53
// check if defined to avoid errors during installation (redirect to admin panel fails if PHP error/warnings are enabled)

54
if(!defined('VERSION')) define('VERSION', '2.8.x');

55
if(!defined('REVISION')) define('REVISION', '1346');

56

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

  
48
if(!defined('WB_URL')) {
49
	header('Location: ../index.php');
50
	exit(0);
51
}
52

  
53
// check if defined to avoid errors during installation (redirect to admin panel fails if PHP error/warnings are enabled)
54
if(!defined('VERSION')) define('VERSION', '2.8.1');
55
if(!defined('REVISION')) define('REVISION', '1347');
56

  
57 57
?>
branches/2.8.x/wb/admin/users/save.php
1
<?php

2
/**

3
 *

4
 * @category        admin

5
 * @package         users

6
 * @author          WebsiteBaker Project

7
 * @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.4.9 and higher

13
 * @version         $Id$

14
 * @filesource		$HeadURL$

15
 * @lastmodified    $Date$

16
 *

17
 */

18

  
19
// Print admin header

20
require('../../config.php');

21
require_once(WB_PATH.'/framework/class.admin.php');

22
$admin = new admin('Access', 'users_modify');

23

  
24
// Create new database object

25
$database = new database();

26

  
27
// Check if user id is a valid number and doesnt equal 1

28
if(!isset($_POST['user_id']) OR !is_numeric($_POST['user_id']) OR $_POST['user_id'] == 1) {

29
	header("Location: index.php");

30
	exit(0);

31
} else {

32
	$user_id = $_POST['user_id'];

33
}

34

  
35
// Gather details entered

36
$groups_id = (isset($_POST['groups'])) ? implode(",", $admin->add_slashes($_POST['groups'])) : '';

37
$active = $admin->add_slashes($_POST['active'][0]);

38
$username_fieldname = $admin->get_post_escaped('username_fieldname');

39
$username = strtolower($admin->get_post_escaped($username_fieldname));

40
$password = $admin->get_post('password');

41
$password2 = $admin->get_post('password2');

42
$display_name = $admin->get_post_escaped('display_name');

43
$email = $admin->get_post_escaped('email');

44
$home_folder = $admin->get_post_escaped('home_folder');

45

  
46
// Create a javascript back link

47
$js_back = "javascript: history.go(-1);";

48

  
49
// Check values

50
if($groups_id == "") {

51
	$admin->print_error($MESSAGE['USERS']['NO_GROUP'], $js_back);

52
}

53
if(strlen($username) < 2) {

54
	$admin->print_error($MESSAGE['USERS']['USERNAME_TOO_SHORT'], $js_back);

55
}

56
if($password != "") {

57
	if(strlen($password) < 2) {

58
		$admin->print_error($MESSAGE['USERS']['PASSWORD_TOO_SHORT'], $js_back);

59
	}

60
	if($password != $password2) {

61
		$admin->print_error($MESSAGE['USERS']['PASSWORD_MISMATCH'], $js_back);

62
	}

63
}

64

  
65
if($email != "")

66
{

67
	if($admin->validate_email($email) == false)

68
    {

69
        $admin->print_error($MESSAGE['USERS']['INVALID_EMAIL'], $js_back);

70
	}

71
} else { // e-mail must be present

72
	$admin->print_error($MESSAGE['SIGNUP']['NO_EMAIL'], $js_back);

73
}

74

  
75
// Check if the email already exists

76
$results = $database->query("SELECT user_id FROM ".TABLE_PREFIX."users WHERE email = '".$admin->add_slashes($_POST['email'])."'");

77
if($results->numRows() > 0)

78
{

79
	if(isset($MESSAGE['USERS']['EMAIL_TAKEN']))

80
    {

81
		$admin->print_error($MESSAGE['USERS']['EMAIL_TAKEN'], $js_back);

82
	} else {

83
		$admin->print_error($MESSAGE['USERS']['INVALID_EMAIL'], $js_back);

84
	}

85
}

86

  
87
// Prevent from renaming user to "admin"

88
if($username != 'admin') {

89
	$username_code = ", username = '$username'";

90
} else {

91
	$username_code = '';

92
}

93

  
94
// Update the database

95
if($password == "") {

96
	$query = "UPDATE ".TABLE_PREFIX."users SET groups_id = '$groups_id', active = '$active'$username_code, display_name = '$display_name', home_folder = '$home_folder', email = '$email' WHERE user_id = '$user_id'";

97
} else {

98
	// MD5 supplied password

99
	$md5_password = md5($password);

100
	$query = "UPDATE ".TABLE_PREFIX."users SET groups_id = '$groups_id', active = '$active'$username_code, display_name = '$display_name', home_folder = '$home_folder', email = '$email', password = '$md5_password' WHERE user_id = '$user_id'";

101
}

102
$database->query($query);

103
if($database->is_error()) {

104
	$admin->print_error($database->get_error());

105
} else {

106
	$admin->print_success($MESSAGE['USERS']['SAVED']);

107
}

108

  
109
// Print admin footer

110
$admin->print_footer();

111

  
1
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         users
6
 * @author          WebsiteBaker Project
7
 * @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.4.9 and higher
13
 * @version         $Id$
14
 * @filesource		$HeadURL$
15
 * @lastmodified    $Date$
16
 *
17
 */
18

  
19
// Print admin header
20
require('../../config.php');
21
require_once(WB_PATH.'/framework/class.admin.php');
22
$admin = new admin('Access', 'users_modify');
23

  
24
// Create new database object
25
$database = new database();
26

  
27
// Check if user id is a valid number and doesnt equal 1
28
if(!isset($_POST['user_id']) OR !is_numeric($_POST['user_id']) OR $_POST['user_id'] == 1) {
29
	header("Location: index.php");
30
	exit(0);
31
} else {
32
	$user_id = $_POST['user_id'];
33
}
34

  
35
// Gather details entered
36
$groups_id = (isset($_POST['groups'])) ? implode(",", $admin->add_slashes($_POST['groups'])) : '';
37
$active = $admin->add_slashes($_POST['active'][0]);
38
$username_fieldname = $admin->get_post_escaped('username_fieldname');
39
$username = strtolower($admin->get_post_escaped($username_fieldname));
40
$password = $admin->get_post('password');
41
$password2 = $admin->get_post('password2');
42
$display_name = $admin->get_post_escaped('display_name');
43
$email = $admin->get_post_escaped('email');
44
$home_folder = $admin->get_post_escaped('home_folder');
45

  
46
// Create a javascript back link
47
$js_back = "javascript: history.go(-1);";
48

  
49
// Check values
50
if($groups_id == "") {
51
	$admin->print_error($MESSAGE['USERS']['NO_GROUP'], $js_back);
52
}
53
if(strlen($username) < 2) {
54
	$admin->print_error($MESSAGE['USERS']['USERNAME_TOO_SHORT'], $js_back);
55
}
56
if($password != "") {
57
	if(strlen($password) < 2) {
58
		$admin->print_error($MESSAGE['USERS']['PASSWORD_TOO_SHORT'], $js_back);
59
	}
60
	if($password != $password2) {
61
		$admin->print_error($MESSAGE['USERS']['PASSWORD_MISMATCH'], $js_back);
62
	}
63
}
64

  
65
if($email != "")
66
{
67
	if($admin->validate_email($email) == false)
68
    {
69
        $admin->print_error($MESSAGE['USERS']['INVALID_EMAIL'], $js_back);
70
	}
71
} else { // e-mail must be present
72
	$admin->print_error($MESSAGE['SIGNUP']['NO_EMAIL'], $js_back);
73
}
74

  
75
// Check if the email already exists
76
$results = $database->query("SELECT user_id FROM ".TABLE_PREFIX."users WHERE email = '".$admin->add_slashes($_POST['email'])."' AND user_id <> '".$user_id."' ");
77
if($results->numRows() > 0)
78
{
79
	if(isset($MESSAGE['USERS']['EMAIL_TAKEN']))
80
    {
81
		$admin->print_error($MESSAGE['USERS']['EMAIL_TAKEN'], $js_back);
82
	} else {
83
		$admin->print_error($MESSAGE['USERS']['INVALID_EMAIL'], $js_back);
84
	}
85
}
86

  
87
// Prevent from renaming user to "admin"
88
if($username != 'admin') {
89
	$username_code = ", username = '$username'";
90
} else {
91
	$username_code = '';
92
}
93

  
94
// Update the database
95
if($password == "") {
96
	$query = "UPDATE ".TABLE_PREFIX."users SET groups_id = '$groups_id', active = '$active'$username_code, display_name = '$display_name', home_folder = '$home_folder', email = '$email' WHERE user_id = '$user_id'";
97
} else {
98
	// MD5 supplied password
99
	$md5_password = md5($password);
100
	$query = "UPDATE ".TABLE_PREFIX."users SET groups_id = '$groups_id', active = '$active'$username_code, display_name = '$display_name', home_folder = '$home_folder', email = '$email', password = '$md5_password' WHERE user_id = '$user_id'";
101
}
102
$database->query($query);
103
if($database->is_error()) {
104
	$admin->print_error($database->get_error());
105
} else {
106
	$admin->print_success($MESSAGE['USERS']['SAVED']);
107
}
108

  
109
// Print admin footer
110
$admin->print_footer();
111

  
112 112
?>
branches/2.8.x/wb/modules/droplets/example/LoginBox.php
1 1
//:Puts a Login / Logout box on your page.
2 2
//:Use: [[LoginBox]]. Remember to enable frontend login in your website settings.
3
global $wb, $TEXT, $MENU;

4
$return_value = " ";

5
if(FRONTEND_LOGIN == 'enabled' && VISIBILITY != 'private' && $wb->get_session('USER_ID') == '') {

6
	$return_value  = '<form name="login" action="'.LOGIN_URL.'" method="post" class="login_table">';

7
	$return_value .= '<h2>'.$TEXT['LOGIN'].'</h2>';

8
	$return_value .= $TEXT['USERNAME'].':<input type="text" name="username" style="text-transform: lowercase;" /><br />';

9
	$return_value .= $TEXT['PASSWORD'].':<input type="password" name="password" /><br />';

10
	$return_value .= '<input type="submit" name="submit" value="'.$TEXT['LOGIN'].'" class="dbutton" /><br />';

11
	$return_value .= '<a href="'.FORGOT_URL.'">'.$TEXT['FORGOT_DETAILS'].'</a><br />';

12
	if(is_numeric(FRONTEND_SIGNUP))  

13
		$return_value .= '<a href="'.SIGNUP_URL.'">'.$TEXT['SIGNUP'].'</a>';

14
	$return_value .= '</form>';

15
} elseif(FRONTEND_LOGIN == 'enabled' && is_numeric($wb->get_session('USER_ID'))) {

16
	$return_value = '<form name="logout" action="'.LOGOUT_URL.'" method="post" class="login_table">';

17
	$return_value .= '<h2>'.$TEXT['LOGGED_IN'].'</h2>';

18
	$return_value .= $TEXT['WELCOME_BACK'].', '.$wb->get_display_name().'<br />';

19
	$return_value .= '<input type="submit" name="submit" value="'.$MENU['LOGOUT'].'" class="dbutton" /><br />';

20
	$return_value .= '<a href="'.PREFERENCES_URL.'">'.$MENU['PREFERENCES'].'</a><br />';

21
	$return_value .= '<a href="'.ADMIN_URL.'/index.php" target="_blank">'.$TEXT['ADMINISTRATION'].'</a>';

22
	$return_value .= '</form>';

23
}

3
global $wb, $TEXT, $MENU;
4
$return_value = " ";
5
if(FRONTEND_LOGIN == 'enabled' && VISIBILITY != 'private' && $wb->get_session('USER_ID') == '') {
6
	$return_value  = '<form name="login" action="'.LOGIN_URL.'" method="post" class="login_table">';
7
	$return_value .= '<h2>'.$TEXT['LOGIN'].'</h2>';
8
	$return_value .= $TEXT['USERNAME'].':<input type="text" name="username" style="text-transform: lowercase;" /><br />';
9
	$return_value .= $TEXT['PASSWORD'].':<input type="password" name="password" /><br />';
10
	$return_value .= '<input type="submit" name="submit" value="'.$TEXT['LOGIN'].'" class="dbutton" /><br />';
11
	$return_value .= '<a href="'.FORGOT_URL.'">'.$TEXT['FORGOT_DETAILS'].'</a><br />';
12
	if(is_numeric(FRONTEND_SIGNUP) && (FRONTEND_SIGNUP > 0))  
13
		$return_value .= '<a href="'.SIGNUP_URL.'">'.$TEXT['SIGNUP'].'</a>';
14
	$return_value .= '</form>';
15
} elseif(FRONTEND_LOGIN == 'enabled' && is_numeric($wb->get_session('USER_ID'))) {
16
	$return_value = '<form name="logout" action="'.LOGOUT_URL.'" method="post" class="login_table">';
17
	$return_value .= '<h2>'.$TEXT['LOGGED_IN'].'</h2>';
18
	$return_value .= $TEXT['WELCOME_BACK'].', '.$wb->get_display_name().'<br />';
19
	$return_value .= '<input type="submit" name="submit" value="'.$MENU['LOGOUT'].'" class="dbutton" /><br />';
20
	$return_value .= '<a href="'.PREFERENCES_URL.'">'.$MENU['PREFERENCES'].'</a><br />';
21
	$return_value .= '<a href="'.ADMIN_URL.'/index.php" target="_blank">'.$TEXT['ADMINISTRATION'].'</a>';
22
	$return_value .= '</form>';
23
}
24 24
return $return_value;

Also available in: Unified diff