| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
db_query("delete from invitations where added < " . (time() - (86400 * 7))); |
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
$sitename = sitename; |
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
if (isset($_REQUEST['action'])) { |
|---|
| 14 |
|
|---|
| 15 |
$_REQUEST['action']) { |
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
case "invite_invite": |
|---|
| 19 |
|
|---|
| 20 |
$_REQUEST['invite_name']) |
|---|
| 21 |
$_REQUEST['invite_email']) |
|---|
| 22 |
$_REQUEST['invite_text']) |
|---|
| 23 |
$_REQUEST['invite_name'] != "" |
|---|
| 24 |
&& $_REQUEST['invite_email'] != "" |
|---|
| 25 |
) { |
|---|
| 26 |
logged_on || public_reg == true) { |
|---|
| 27 |
$email = trim(stripslashes($_REQUEST['invite_email'])); |
|---|
| 28 |
preg_match ('/^[^ \@\n\r\t\']+\@[^ \@\n\r\t\']+\.[^ \@\n\r\t\'][^ \@\n\r\t\']+$/', $email)) { |
|---|
| 29 |
$email = addslashes($email); |
|---|
| 30 |
$strippedname = stripslashes($_REQUEST['invite_name']); |
|---|
| 31 |
$name = addslashes($strippedname); |
|---|
| 32 |
$invitations = db_query("select count(*) as num_invitations from invitations where email = '$email'"); |
|---|
| 33 |
$invitations = $invitations[0]->num_invitations; |
|---|
| 34 |
$invitations == 0) { |
|---|
| 35 |
$accounts = db_query("select ident, username from users where email = '$email'"); |
|---|
| 36 |
sizeof($accounts) ==0) { |
|---|
| 37 |
$code = substr(md5(time() . $_SESSION['username']),0,7); |
|---|
| 38 |
db_query("insert into invitations set name = '$name', email = '$email', code='$code', added = " . time() . ", owner = " . $_SESSION['userid']); |
|---|
| 39 |
$_REQUEST['invite_text'] != "") { |
|---|
| 40 |
$invitetext = gettext("They included the following message:") . "\n\n----------\n" . stripslashes($_REQUEST['invite_text']) . "\n----------"; |
|---|
| 41 |
|
|---|
| 42 |
$url = url . "_invite/join.php?invitecode=" . $code; |
|---|
| 43 |
logged_on) { |
|---|
| 44 |
$greetingstext = sprintf(gettext("Thank you for registering with %s."),$sitename); |
|---|
| 45 |
$subjectline = sprintf(gettext("%s account verification"),$sitename); |
|---|
| 46 |
$from_email = email; |
|---|
| 47 |
|
|---|
| 48 |
$greetingstext = $_SESSION['name'] . " " . gettext("has invited you to join") ." $sitename, ". gettext("a learning landscape system.") .""; |
|---|
| 49 |
$subjectline = $_SESSION['name'] . " " . gettext("has invited you to join") ." $sitename"; |
|---|
| 50 |
$from_email = $_SESSION['email']; |
|---|
| 51 |
|
|---|
| 52 |
$emailmessage = sprintf(gettext("Dear %s,\n\n%s %s\n\nTo join, visit the following URL:\n\n\t%s\n\nYour email address has not been passed onto any third parties, and will be removed from our system within seven days.\n\nRegards,\n\nThe %s team."),$strippedname,$greetingstext,$invitetext,$url, $sitename); |
|---|
| 53 |
$emailmessage = wordwrap($emailmessage); |
|---|
| 54 |
$messages[] = sprintf(gettext("Your invitation was sent to %s at %s. It will be valid for seven days."),$strippedname,$email); |
|---|
| 55 |
mail($email,$subjectline,$emailmessage,"From: $sitename <".$from_email.">"); |
|---|
| 56 |
|
|---|
| 57 |
$messages[] = sprintf(gettext("User %s already has that email address. Invitation not sent."),$accounts[0]->username); |
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 |
$messages[] = gettext("Someone with that email address has already been invited to the system. "); |
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 |
$messages[] = gettext("Invitation failed: The email address was not valid."); |
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 |
$messages[] = gettext("Invitation failed: you must specify both a name and an email address."); |
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
case "invite_join": |
|---|
| 75 |
|
|---|
| 76 |
$_REQUEST['join_name']) && |
|---|
| 77 |
$_REQUEST['invitecode']) && |
|---|
| 78 |
$_REQUEST['over13']) && |
|---|
| 79 |
$_REQUEST['join_username']) && |
|---|
| 80 |
$_REQUEST['join_password1']) && |
|---|
| 81 |
$_REQUEST['join_password2']) |
|---|
| 82 |
|
|---|
| 83 |
$code = trim($_REQUEST['invitecode']); |
|---|
| 84 |
$details = db_query("select * from invitations where code = '$code'"); |
|---|
| 85 |
sizeof($details) == 0) { |
|---|
| 86 |
$messages[] = gettext("Error! Invalid invite code."); |
|---|
| 87 |
|
|---|
| 88 |
$_REQUEST['join_password1'] != $_REQUEST['join_password2'] |
|---|
| 89 |
strlen($_REQUEST['join_password1']) < 6 |
|---|
| 90 |
|| strlen($_REQUEST['join_password1']) > 16) { |
|---|
| 91 |
$messages[] = gettext("Error! Invalid password. Your passwords must match and be between 6 and 16 characters in length."); |
|---|
| 92 |
|
|---|
| 93 |
preg_match("/^[A-Za-z0-9]{3,12}$/",$_REQUEST['join_username'])) { |
|---|
| 94 |
$messages[] = gettext("Error! Your username must contain letters and numbers only, cannot be blank, and must be between 3 and 12 characters in length."); |
|---|
| 95 |
|
|---|
| 96 |
$username = strtolower(trim($_REQUEST['join_username'])); |
|---|
| 97 |
$usernametaken = db_query("select count(*) as taken from users where username = '$username'"); |
|---|
| 98 |
$usernametaken = $usernametaken[0]->taken; |
|---|
| 99 |
$usernametaken > 0) { |
|---|
| 100 |
$messages[] = gettext("The username '$username' is already taken by another user. You will need to pick a different one."); |
|---|
| 101 |
|
|---|
| 102 |
$name = trim($_REQUEST['join_name']); |
|---|
| 103 |
$displaypassword = $_REQUEST['join_password1']; |
|---|
| 104 |
$password = md5($_REQUEST['join_password1']); |
|---|
| 105 |
$details = $details[0]; |
|---|
| 106 |
$email = $details->email; |
|---|
| 107 |
$ident = run("users:create", array("name" => $name, |
|---|
| 108 |
"password" => $password, |
|---|
| 109 |
"username" => $username, |
|---|
| 110 |
"email" => $email)); |
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| 113 |
|
|---|
| 114 |
$owner = (int) $details->owner; |
|---|
| 115 |
$owner != -1) { |
|---|
| 116 |
db_query("insert into friends set owner = $owner, friend = $ident"); |
|---|
| 117 |
db_query("insert into friends set owner = $ident, friend = $owner"); |
|---|
| 118 |
|
|---|
| 119 |
$owner != 1) { |
|---|
| 120 |
db_query("insert into friends set owner = $ident, friend = 1"); |
|---|
| 121 |
|
|---|
| 122 |
$rssresult = run("weblogs:rss:publish", array($ident, false)); |
|---|
| 123 |
$rssresult = run("files:rss:publish", array($ident, false)); |
|---|
| 124 |
$rssresult = run("profile:rss:publish", array($ident, false)); |
|---|
| 125 |
$_SESSION['messages'][] = gettext("Your account was created! You can now log in using the username and password you supplied. You have been sent an email containing these details for reference purposes."); |
|---|
| 126 |
db_query("delete from invitations where code = '$code'"); |
|---|
| 127 |
mail($email, sprintf(gettext("Your %s account"),$sitename), wordwrap(sprintf(gettext("Thanks for joining %s!\n\nFor your records, your %s username and password are:\n\n\tUsername: %s\n\tPassword: %s\n\nYou can log in at any time by visiting %s and entering these details into the login form.\n\nWe hope you enjoy using the system.\n\nRegards,\n\nThe %s Team"),$sitename,$sitename,$username,$displaypassword,url,$sitename)), "From: $sitename <".email.">"); |
|---|
| 128 |
header("Location: " . url); |
|---|
| 129 |
|
|---|
| 130 |
|
|---|
| 131 |
|
|---|
| 132 |
|
|---|
| 133 |
|
|---|
| 134 |
|
|---|
| 135 |
$messages[] = gettext("You must indicate that you are at least 13 years old to join."); |
|---|
| 136 |
|
|---|
| 137 |
|
|---|
| 138 |
|
|---|
| 139 |
|
|---|
| 140 |
|
|---|
| 141 |
|
|---|
| 142 |
case "invite_password_request": |
|---|
| 143 |
$_REQUEST['password_request_name'])) { |
|---|
| 144 |
$users = db_query("select ident, email from users where username = '".trim($_REQUEST['password_request_name'])."' and user_type = 'person'"); |
|---|
| 145 |
sizeof($users) > 0) { |
|---|
| 146 |
$code = substr(md5(time() . $_REQUEST['password_request_name']),0,7); |
|---|
| 147 |
$ident = $users[0]->ident; |
|---|
| 148 |
db_query("insert into password_requests set code = '$code', owner = $ident"); |
|---|
| 149 |
$url = url . "_invite/new_password.php?passwordcode=" . $code; |
|---|
| 150 |
mail(stripslashes($users[0]->email), sprintf(gettext("Verify your %s account password request"),$sitename), wordwrap(sprintf(gettext("A request has been received to generate your account at %s a new password.\n\nTo confirm this request and receive a new password by email, please click the following link:\n\n\t%s\n\nPlease let us know if you have any further problems.\n\nRegards,\n\nThe %s Team"),$sitename,$url,$sitename)), "From: $sitename <".email.">"); |
|---|
| 151 |
$messages[] = gettext("Your verification email was sent. Please check your inbox."); |
|---|
| 152 |
|
|---|
| 153 |
$messages[] = gettext("No user with that username was found."); |
|---|
| 154 |
|
|---|
| 155 |
|
|---|
| 156 |
|
|---|
| 157 |
|
|---|
| 158 |
|
|---|
| 159 |
|
|---|
| 160 |
|
|---|
| 161 |
|
|---|
| 162 |
?> |
|---|