Diff Revisions 521 vs 549 for /branches/0.9/functions/register.php
| 521 | 549 | <- Revisions | |
|
Diff lines for: Rev 521 : Lines 11 -> 20 Rev 549 : Lines 11 -> 20 |
|||
| 11 | 11 | Additional license terms at http://eocms.com/license.html | |
| 12 | 12 | */ | |
| 13 | 13 | function register($username, $password, $vpassword, $email, $token, $captcha, $tos) { | |
| 14 | - | global $settings; | |
| 14 | + | global $settings, $error, $error_die; | |
| 15 | 15 | call('checktoken', $token); | |
| 16 | 16 | if(!empty($settings['tos']) && $tos != 'on') { | |
| 17 | - | $_SESSION['error'] = 'You must agree to the Terms of Service to register'; | |
| 17 | + | $error[] = 'You must agree to the Terms of Service to register'; | |
| 18 | 18 | return false; | |
| 19 | 19 | } | |
| 20 | 20 | if($settings['register_captcha'] =='on') | |
|
Diff lines for: Rev 521 : Lines 24 -> 60 Rev 549 : Lines 24 -> 64 |
|||
| 24 | 24 | $sql = call('sql_query', "SELECT * FROM users WHERE user = '$username'"); | |
| 25 | 25 | $fetch = call('sql_fetch_array',$sql); | |
| 26 | 26 | if ($fetch['user'] == $username) { | |
| 27 | - | $_SESSION['error'] = 'Username is already taken!'; | |
| 27 | + | $error[] = 'Username is already taken!'; | |
| 28 | 28 | return false; | |
| 29 | 29 | } | |
| 30 | 30 | if (empty($username)) { | |
| 31 | - | $_SESSION['error'] = 'You did not enter a username'; //idiot how on earth are people meant to know who u are! | |
| 31 | + | $error[] = 'You did not enter a username'; //idiot how on earth are people meant to know who u are! | |
| 32 | 32 | return false; | |
| 33 | 33 | } | |
| 34 | 34 | if (strlen($password) < 6) { | |
| 35 | - | $_SESSION['error'] = 'password must be 6 characters or longer!'; | |
| 35 | + | $error[] = 'password must be 6 characters or longer!'; | |
| 36 | 36 | return false; | |
| 37 | 37 | } | |
| 38 | 38 | $decodedusername = str_replace('<', '<', $username); | |
| 39 | 39 | $decodedusername = str_replace('>', '>', $decodedusername); | |
| 40 | 40 | if (strlen($decodedusername) > 16) { | |
| 41 | - | $_SESSION['error'] = 'Your username is too long, it must be below 16 characters'; | |
| 41 | + | $error[] = 'Your username is too long, it must be below 16 characters'; | |
| 42 | 42 | return false; | |
| 43 | 43 | } | |
| 44 | 44 | if ($password != $vpassword) { | |
| 45 | - | $_SESSION['error'] = 'The passwords entered to do not match'; | |
| 45 | + | $error[] = 'The passwords entered to do not match'; | |
| 46 | 46 | return false; | |
| 47 | 47 | } | |
| 48 | 48 | if (!preg_match("/^([a-z0-9._-](\+[a-z0-9])*)+@[a-z0-9.-]+\.[a-z]{2,6}$/i", $email)) { | |
| 49 | - | $_SESSION['error'] = 'The email address entered is not valid'; | |
| 49 | + | $error[] = 'The email address entered is not valid'; | |
| 50 | 50 | return false; | |
| 51 | 51 | } | |
| 52 | + | if (strpos($username, ',') !== false) { | |
| 53 | + | $error[] = 'Commas (,) are not allowed in a username'; | |
| 54 | + | return false; | |
| 55 | + | } | |
| 52 | 56 | if ($settings['register_approval'] == 'none') | |
| 53 | 57 | $group = '2'; | |
| 54 | 58 | else | |
| 55 | 59 | $group = '1'; | |
| 56 | - | if (!isset($_SESSION['error']) && !isset($_SESSION['error_die'])) { | |
| 57 | - | $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']."')"); | |
| 60 | + | if(!errors()) { | |
| 61 | + | $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']."')"); | |
| 58 | 62 | if($sql) | |
| 59 | 63 | return true; | |
| 60 | 64 | if ($settings['register_approval'] == 'email') { | |
|
Diff lines for: Rev 521 : Lines 82 -> 88 Rev 549 : Lines 86 -> 88 |
|||
| 82 | 86 | $mail->Subject = 'Account Activation at' . $settings['site_name'] . ''; | |
| 83 | 87 | $mail->Body = "Please click the following link to activate your account:\n--------\n" . $settings['site_url'] . "/index.php?act=activate&$key_string"; | |
| 84 | 88 | if (!$mail->Send()) { | |
| 85 | - | $_SESSION['error'] = "Error sending: " . $mail->ErrorInfo; | |
| 89 | + | $error[] = "Error sending: " . $mail->ErrorInfo; | |
| 86 | 90 | return false; | |
| 87 | 91 | } | |
| 88 | 92 | } | |
View this file contents
View the full history
Commits for banancanard-eoCMS:/branches/0.9/functions/register.php