1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
<?php
/* eoCMS � 2007 - 2010, a Content Management System
by James Mortemore, Ryan Matthews
http://www.eocms.com
is licenced under a Creative Commons
Attribution-Share Alike 2.0 UK: England & Wales Licence.
Permissions beyond the scope of this licence
may be available at http://creativecommons.org/licenses/by-sa/2.0/uk/.
Additional licence terms at http://eocms.com/licence.html
*/
function register($username, $password, $vpassword, $email, $token, $captcha, $tos) {
global $settings, $error, $error_die;
call('checktoken', $token);
if(!empty($settings['tos']) && $tos != 'on') {
$error[] = 'You must agree to the Terms of Service to register';
return false;
}
if($settings['register_captcha'] =='on')
$captcha = call('captchacheck', $captcha);
if($settings['register_captcha'] =='on' && $captcha == false)
return false;
$sql = call('sql_query', "SELECT user FROM users WHERE user = '$username'");
if (call('sql_num_rows', $sql) != 0) {
$error[] = 'Username is already taken';
return false;
}
$sql = call('sql_query', "SELECT email FROM users WHERE email = '$email'");
if (call('sql_num_rows', $sql) != 0) {
$error[] = 'Email address is already in use';
return false;
}
if (empty($username)) {
$error[] = 'You did not enter a username'; //idiot how on earth are people meant to know who u are!
return false;
}
if (strlen($password) < 6) {
$error[] = 'password must be 6 characters or longer!';
return false;
}
$decodedusername = html_entity_decode($username, ENT_QUOTES);
if (strlen($decodedusername) > 16) {
$error[] = 'Your username is too long, it must be below 16 characters';
return false;
}
if ($password != $vpassword) {
$error[] = 'The passwords entered to do not match';
return false;
}
if (!preg_match("/^([a-z0-9._-](\+[a-z0-9])*)+@[a-z0-9.-]+\.[a-z]{2,6}$/i", $email)) {
$error[] = 'The email address entered is not valid';
return false;
}
if (strpos($username, ',') !== false) {
$error[] = 'Commas (,) are not allowed in a username';
return false;
}
if ($settings['register_approval'] == 'none')
$group = '2';
else
$group = '1';
if(!errors()) {
$sql = call('sql_query', "INSERT INTO users (user, pass, email, ip, regdate, lastlogin, membergroup, theme) VALUES('$username', '$password', '$email', '" . call('visitor_ip') . "', '" . time() . "', 'Never', '$group', '".$settings['site_theme']."')");
if($settings['register_approval'] == 'email') {
$mail = new PHPMailer();
//last inserted ID
$id = call('sql_insert_id');
//Generate MD5 hash key
$key = call('generate_key', 6);
//Put together the key string
$key_string = "key=$key&id=$id";
//Insert into database
$query = call('sql_query', "INSERT INTO activation_keys (user_id , key_number) VALUES ('$id', '$key')");
if ($settings['mail'] == 'sendmail')
$mail->IsMail();
elseif ($settings['mail'] == 'smtp') {
$mail->IsSMTP();
$mail->Host = $settings['smtp_host'];
$mail->SMTPAuth = true;
$mail->Username = $settings['smtp_username'];
$mail->Password = $settings['smtp_password'];
}
$mail->FromName = $settings['site_name'];
$mail->From = $settings['email'];
$mail->AddAddress("$email");
$mail->Subject = 'Account Activation at' . $settings['site_name'] . '';
$mail->Body = "Please click the following link to activate your account:\n--------\n" . $settings['site_url'] . "/index.php?act=activate&$key_string";
if (!$mail->Send()) {
$error[] = "Error sending: " . $mail->ErrorInfo;
return false;
}
else
return true;
} else
return true;
}
}
?>
|
History for banancanard-eoCMS/branches/0.9/functions/register.php
| Revision | Author | Commited | Message |
|---|---|---|---|
825
Diff
|
|
Tue 11 May, 2010 17:50:24 +0000 | Fixed register function, should now return true and success message now display upon registering |
805
Diff
|
|
Sat 27 Feb, 2010 12:47:40 +0000 | Register will now check if the email address is already in use by another user, if it is, it will output an error |
784
Diff
|
|
Wed 06 Jan, 2010 19:07:42 +0000 | Change the 0.9 branch licence to the Creative Commons Share-Alike 2.0 England and Wales |
776
Diff
|
|
Mon 21 Dec, 2009 11:19:20 +0000 | Fixed email activation and fixed the max length of a topic reply to include the RE: character count in 0.9 branch |
702
Diff
|
|
Mon 05 Oct, 2009 21:47:21 +0000 | Added 0.9 branch |
701
Diff
|
|
Mon 05 Oct, 2009 21:43:44 +0000 | Moved all files into trunk |
549
Diff
|
|
Sat 22 Aug, 2009 16:12:48 +0000 | Changed $_SESSION[‘error’] to $error and $_SESSION[‘error_die’] to $error_die variables. Multiple errors are now outputted instead of one per page load. Changed login system, to use a cookie instead of sessions due to PHP’s “bug” with setting sessions for the entire site meaning there was conflict with other installations of eoCMS. |
521
Diff
|
|
Sun 09 Aug, 2009 12:36:35 +0000 | Added support for ToS |
464
Diff
|
|
Sun 02 Aug, 2009 18:33:34 +0000 | Converted captcha image into function. Cleaned up register function |
| 1 |
|
Thu 02 Apr, 2009 19:21:11 +0000 | All files upload |
Diff
View complete history
Commits for banancanard-eoCMS:/branches/0.9/functions/register.php