This repository has been archived by the owner on Nov 11, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindexproc.php
executable file
·55 lines (52 loc) · 1.83 KB
/
indexproc.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
<?php
include("functions.php");
date_default_timezone_set('America/Chicago');
require_once('class.phpmailer.php');
$flag = strpos($_POST['email'],'@');
if (!($flag === false))
die('<font color="red">Only enter your username (not full email address)</font>');
$to = $_POST['email'] . Settings::$validEmailDomain;
$emailFrags = explode('.',$_POST['email']);
$first = ucfirst($emailFrags[0]);
$last = ucfirst($emailFrags[1]);
$toName = $first . ' ' . $last;
$token = md5(microtime() . $_POST['email']);
$db = db_connect();
$stmt = $db->stmt_init();
// Delete previous tokens for this user if they exist
if ($stmt->prepare("DELETE FROM `queue` WHERE `username`=?"))
{
$stmt->bind_param('s',$_POST['email']);
$stmt->execute();
}
// Insert new token
if ($stmt->prepare("INSERT INTO `queue` (`username`,`token`) VALUES (?,?)"))
{
$stmt->bind_param('ss',$_POST['email'],$token);
$stmt->execute();
$stmt->close();
}
$db->close();
$mail = new PHPMailer();
$link = Settings::$baseurl .'quiz.php?token=' . $token;
$body = "Hi $first $last!\r\n";
$body .= "The " . Date('Y') . " edition of Wartburg's is ready and waiting for you as requested.\r\n";
$body .= "Click on the following link to get started. \r\n" . $link . "\r\n\r\nThank you!\r\nWartburg Computer Club\r\n";
$mail->IsSMTP();
//$mail->SMTPDebug = 2;
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->Username = "[email protected]";
$mail->Password = "datepass";
$mail->SetFrom("[email protected]",Settings::$envelopeFrom);
$mail->Subject = "Pending Quiz";
$mail->Body = $body;
$mail->AddAddress($to,$toName);
if(!$mail->Send()) {
echo "<font color=\"red\">Mailer Error: " . $mail->ErrorInfo . '</font>';
} else {
echo "<font color=\"green\">We sent you a message with a link to the quiz! Thanks for signing up.</font>";
}
?>