-
Notifications
You must be signed in to change notification settings - Fork 0
/
invite.php
64 lines (49 loc) · 1.77 KB
/
invite.php
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
<?php
require("web_vars.php");
require("mysql_connect.php");
require_once("verify_email.php");
$invite_text_format = "Hey %s,
Thanks for signing up for nChooseThree, an MIT-exclusive service that lets you match up your friends, and check out matches your friends have suggested for you! To activate your account, please visit
%s
Using nChooseThree, you can:
- Suggest matches between friends and get notified if they all accept
- View, respond to, and ask about match suggestions from friends
Privacy and security are our top priorities - you always remain anonymous unless romantic interest turns out to be mutual. You can find out more about us at
%s
Cheers,
nChooseThree";
function is_registered($email) {
$query = "SELECT * FROM Accounts WHERE Email='$email'";
$res = mysql_query($query);
return mysql_num_rows($res) > 0;
}
function invite($mail) {
global $from_addr, $invite_text_format, $base_url;
$mail = strtolower($mail);
if(!is_registered($mail)) {
return;
}
$hash = sha1($mail . time());
$mail_title = "Activate your nChooseThree account";
$mail_text = sprintf($invite_text_format, $mail, $base_url . "register.php?a=".$hash, $base_url . "about.php");
mail($mail,$mail_title,$mail_text,"From: ".$from_addr);
$mail = mysql_real_escape_string($mail);
$query = "DELETE FROM Invites WHERE Email='$mail'";
mysql_query($query);
$query = "INSERT INTO Invites VALUES ('$mail','$hash')";
mysql_query($query);
}
if(isset($_POST["email"]) and is_email_valid($_POST["email"]) and !is_registered(strtolower($_POST["email"]))) {
invite($_POST["email"]);
include("header.php");
?>
<article>
An email has been sent to your address. Please click the link in the email to complete registration.
</article>
<?php
include("footer.php");
} else {
header("Location: index.php");
die();
}
?>