-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsendemail.php
67 lines (67 loc) · 2.19 KB
/
sendemail.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
65
66
67
<!DOCTYPE HTML>
<?php
require_once "mysql.php";
include "analyze.php";
include "admin/email_user.php";
ini_set('sendmail_from', '[email protected]');
?><html>
<head>
<title>Start Start Tree Scheduling</title>
<meta name="viewport" content="width=device-width, user-scalable=no" />
<link href="/trees.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="header">
<h2><a href="index.php">Start Tree Shift Scheduling</a> > Send Email</h2>
</div>
<div class="colmask fullpage">
<div class="col1">
<p>Please check your email for a message from [email protected] with a start link in it (search your junk and spam folder too!). You will need to use that link to start your schedule.</p>
<p>If you do not receive an email, please <a href="index.php">try again</a> and carefully type in your email.</p>
<p>For privacy reasons, this page does not confirm success or failure.</p>
<?php
$pathparts = pathinfo($_SERVER['SCRIPT_NAME']);
$dirname = $pathparts['dirname'];
$START = "now";
if (isset($_POST['email'])) {
$email = strtolower($_POST['email']);
$mysqli = db_connect();
if ($mysqli !== FALSE) {
$query = "SELECT opt_start FROM options";
if (($result = $mysqli->query($query)) !== FALSE) {
while ($row = $result->fetch_array()) {
$ts = strtotime($row['opt_start']);
$START = strftime("%l:%M %p %A, %B %e, %Y", $ts);
}
$result->close();
}
$email = $mysqli->escape_string($email);
$theemail = $email;
$query = "SELECT * FROM emails WHERE email = '$email'";
if (($result = $mysqli->query($query)) !== FALSE) {
while ($row = $result->fetch_array()) {
$email = $row['pemail'];
}
}
$query = "SELECT * FROM parents WHERE email = '$email'";
if (($result = $mysqli->query($query)) !== FALSE) {
$count = 0;
while (($arr = $result->fetch_array())) {
send_the_email($arr['pname'], $arr['password'], $arr['troop'], $email, $dirname, $theemail);
}
if ($count == 0) {
error_log("No match on $email?");
}
} else {
error_log("Unable to query " . $email . ": " . $mysqli->error);
}
$result->close();
} else {
error_log("Unable to load database");
}
}
?>
</div>
</div>
</body>
</html>