1 |
1386
|
Luisehahne
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
*
|
4 |
|
|
* @category frontend
|
5 |
|
|
* @package account
|
6 |
|
|
* @author WebsiteBaker Project
|
7 |
|
|
* @copyright 2004-2009, Ryan Djurovich
|
8 |
|
|
* @copyright 2009-2011, 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 5.2.2 and higher
|
13 |
|
|
* @version $Id$
|
14 |
|
|
* @filesource $HeadURL$
|
15 |
|
|
* @lastmodified $Date$
|
16 |
|
|
*
|
17 |
|
|
*/
|
18 |
|
|
|
19 |
|
|
if(!defined('WB_URL')) {
|
20 |
|
|
header('Location: ../pages/index.php');
|
21 |
|
|
exit(0);
|
22 |
|
|
}
|
23 |
|
|
|
24 |
|
|
require_once(WB_PATH.'/framework/class.wb.php');
|
25 |
|
|
$wb = new wb('Start', 'start', false, false);
|
26 |
|
|
|
27 |
|
|
// Create new database object
|
28 |
|
|
// $database = new database();
|
29 |
|
|
|
30 |
|
|
// Get details entered
|
31 |
|
|
$groups_id = FRONTEND_SIGNUP;
|
32 |
|
|
$active = 1;
|
33 |
|
|
$username = strtolower(strip_tags($wb->get_post_escaped('username')));
|
34 |
|
|
$display_name = strip_tags($wb->get_post_escaped('display_name'));
|
35 |
|
|
$email = $wb->get_post('email');
|
36 |
|
|
|
37 |
1400
|
FrankH
|
if (!$wb->checkFTAN())
|
38 |
|
|
{
|
39 |
|
|
$wb->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], WB_URL);
|
40 |
|
|
exit();
|
41 |
|
|
}
|
42 |
|
|
|
43 |
1386
|
Luisehahne
|
// Create a javascript back link
|
44 |
|
|
$js_back = "javascript: history.go(-1);";
|
45 |
|
|
|
46 |
|
|
// Check values
|
47 |
|
|
if($groups_id == "") {
|
48 |
|
|
$wb->print_error($MESSAGE['USERS']['NO_GROUP'], $js_back, false);
|
49 |
|
|
}
|
50 |
|
|
if(strlen($username) < 3) {
|
51 |
|
|
$wb->print_error($MESSAGE['USERS']['USERNAME_TOO_SHORT'], $js_back, false);
|
52 |
|
|
}
|
53 |
|
|
if($email != "") {
|
54 |
|
|
if($wb->validate_email($email) == false) {
|
55 |
|
|
$wb->print_error($MESSAGE['USERS']['INVALID_EMAIL'], $js_back, false);
|
56 |
|
|
}
|
57 |
|
|
} else {
|
58 |
|
|
$wb->print_error($MESSAGE['SIGNUP']['NO_EMAIL'], $js_back, false);
|
59 |
|
|
}
|
60 |
|
|
|
61 |
|
|
$email = $wb->add_slashes($email);
|
62 |
|
|
|
63 |
|
|
// Captcha
|
64 |
|
|
if(ENABLED_CAPTCHA) {
|
65 |
|
|
if(isset($_POST['captcha']) AND $_POST['captcha'] != ''){
|
66 |
|
|
// Check for a mismatch
|
67 |
|
|
if(!isset($_POST['captcha']) OR !isset($_SESSION['captcha']) OR $_POST['captcha'] != $_SESSION['captcha']) {
|
68 |
|
|
$wb->print_error($MESSAGE['MOD_FORM']['INCORRECT_CAPTCHA'], $js_back, false);
|
69 |
|
|
}
|
70 |
|
|
} else {
|
71 |
|
|
$wb->print_error($MESSAGE['MOD_FORM']['INCORRECT_CAPTCHA'], $js_back, false);
|
72 |
|
|
}
|
73 |
|
|
}
|
74 |
|
|
if(isset($_SESSION['captcha'])) { unset($_SESSION['captcha']); }
|
75 |
|
|
|
76 |
|
|
// Generate a random password then update the database with it
|
77 |
|
|
$new_pass = '';
|
78 |
|
|
$salt = "abchefghjkmnpqrstuvwxyz0123456789";
|
79 |
|
|
srand((double)microtime()*1000000);
|
80 |
|
|
$i = 0;
|
81 |
|
|
while ($i <= 7) {
|
82 |
|
|
$num = rand() % 33;
|
83 |
|
|
$tmp = substr($salt, $num, 1);
|
84 |
|
|
$new_pass = $new_pass . $tmp;
|
85 |
|
|
$i++;
|
86 |
|
|
}
|
87 |
|
|
$md5_password = md5($new_pass);
|
88 |
|
|
|
89 |
|
|
// Check if username already exists
|
90 |
|
|
$results = $database->query("SELECT user_id FROM ".TABLE_PREFIX."users WHERE username = '$username'");
|
91 |
|
|
if($results->numRows() > 0) {
|
92 |
|
|
$wb->print_error($MESSAGE['USERS']['USERNAME_TAKEN'], $js_back, false);
|
93 |
|
|
}
|
94 |
|
|
|
95 |
|
|
// Check if the email already exists
|
96 |
|
|
$results = $database->query("SELECT user_id FROM ".TABLE_PREFIX."users WHERE email = '".$wb->add_slashes($email)."'");
|
97 |
|
|
if($results->numRows() > 0) {
|
98 |
|
|
if(isset($MESSAGE['USERS']['EMAIL_TAKEN'])) {
|
99 |
|
|
$wb->print_error($MESSAGE['USERS']['EMAIL_TAKEN'], $js_back, false);
|
100 |
|
|
} else {
|
101 |
|
|
$wb->print_error($MESSAGE['USERS']['INVALID_EMAIL'], $js_back, false);
|
102 |
|
|
}
|
103 |
|
|
}
|
104 |
|
|
|
105 |
|
|
// MD5 supplied password
|
106 |
|
|
$md5_password = md5($new_pass);
|
107 |
|
|
|
108 |
|
|
// Inser the user into the database
|
109 |
|
|
$query = "INSERT INTO ".TABLE_PREFIX."users (group_id,groups_id,active,username,password,display_name,email) VALUES ('$groups_id', '$groups_id', '$active', '$username','$md5_password','$display_name','$email')";
|
110 |
|
|
$database->query($query);
|
111 |
|
|
|
112 |
|
|
if($database->is_error()) {
|
113 |
|
|
// Error updating database
|
114 |
|
|
$message = $database->get_error();
|
115 |
|
|
} else {
|
116 |
|
|
// Setup email to send
|
117 |
|
|
$mail_to = $email;
|
118 |
|
|
$mail_subject = $MESSAGE['SIGNUP2']['SUBJECT_LOGIN_INFO'];
|
119 |
|
|
|
120 |
|
|
// Replace placeholders from language variable with values
|
121 |
|
|
$search = array('{LOGIN_DISPLAY_NAME}', '{LOGIN_WEBSITE_TITLE}', '{LOGIN_NAME}', '{LOGIN_PASSWORD}');
|
122 |
|
|
$replace = array($display_name, WEBSITE_TITLE, $username, $new_pass);
|
123 |
|
|
$mail_message = str_replace($search, $replace, $MESSAGE['SIGNUP2']['BODY_LOGIN_INFO']);
|
124 |
|
|
|
125 |
|
|
// Try sending the email
|
126 |
|
|
if($wb->mail(SERVER_EMAIL,$mail_to,$mail_subject,$mail_message)) {
|
127 |
|
|
$display_form = false;
|
128 |
|
|
$wb->print_success($MESSAGE['FORGOT_PASS']['PASSWORD_RESET'], WB_URL.'/account/login.php');
|
129 |
|
|
} else {
|
130 |
|
|
$database->query("DELETE FROM ".TABLE_PREFIX."users WHERE username = '$username'");
|
131 |
|
|
$wb->print_error($MESSAGE['FORGOT_PASS']['CANNOT_EMAIL'], $js_back, false);
|
132 |
|
|
}
|
133 |
|
|
}
|
134 |
|
|
|
135 |
|
|
?>
|