} $result->close(); } $query = "SELECT * FROM parents"; if (($result = $mysqli->query($query)) !== FALSE) { while ($arr = $result->fetch_array()) { $idx = $arr['id']; $parents[$idx] = $arr; } } $result->close(); foreach ($parents as $parentid => $parent) { $query = "SELECT email FROM emails WHERE pemail = '" . $parent['email'] . "';"; if (($result = $mysqli->query($query)) !== FALSE) { while ($arr = $result->fetch_array()) { send_the_email($parent['pname'], $parent['password'], $parent['troop'], $arr['email'], $dirname); $n++; print "{$n}. Sending mail to " . $parent['pname'] . " (" . $arr['email'] . ")<br/>\n"; } } } $result->close(); } else { print "<b>Unable to load database</b><br/>\n"; } ?> </div> </div> </body> </html>
} $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>
} } else { $total_state = ""; } if ($parent['do_not_nag'] != 0) { $complete = true; } if (!$complete) { if (empty($scout_state)) { $scout_state = "<li style='color:green'>OK</li>"; } // Send the nag email to everyone $query = "SELECT email FROM emails WHERE pemail = '" . $parent['email'] . "';"; if (($result = $mysqli->query($query)) !== FALSE) { while ($arr = $result->fetch_array()) { send_the_email($parent['pname'], $parent['password'], $arr['email'], "https://www.treesale.christmas", $snow_state, $parent_state, $scout_state, $total_state); } $result->close(); } } } function send_the_email($pname, $password, $email, $dirname, $snow_state, $parent_state, $scout_state, $total_state) { global $START; $stats = analyze(); $subject = "Please complete your Tree Scheduling"; $myemail = '*****@*****.**'; $boundary = "TreesTreesBeautifulTrees"; $headers = 'From: Todd Short <*****@*****.**>' . "\r\n"; $headers .= 'Bcc: todd.short@me.com' . "\r\n"; $headers .= "MIME-Version: 1.0\r\n";