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