/** * Sends an E-Mail to the offerer of the book. * * Known usages: * - add.php * - book.php - "Anfrage: " * - Cleaner.php - "Erneuern: " * * @param int $bookId database id of th book, this mail is about * @param string $subjectStart beginning of the subject, the title will * follow * @param string $message some text for the user, greeting will be added * @param string $replyTo mail address for the Reply-To field (optional) * @return bool false on failure */ public static function send($bookId, $subjectStart, $message, $replyTo = null) { include_once 'mysql_conn.php'; $query = 'select mail, id, author, title, price, year, isbn,' . ' description, auth_key from books where id="' . $bookId . '"'; $result = mysql_query($query); if (mysql_num_rows($result) != 1) { return false; } $book = Book::fromMySql($result); $subject = $subjectStart . $book->get('title'); $tmpl = Template::fromFile('view/mail.txt'); $tmpl->assign('message', $message); $tmpl->assign('bookText', $book->asText()); if ($replyTo == null || $replyTo == $book->get('mail')) { $subTmpl = $tmpl->addSubtemplate('editBook'); $link = self::editLink($book->get('id'), $book->get('auth_key')); $subTmpl->assign('editLink', $link); $books = new UsersBooks($book->get('mail')); $subTmpl->assign('usersBooks', $books->toString()); } else { $subTmpl = $tmpl->addSubtemplate('viewBook'); $link = self::bookLink($book->get('id')); $subTmpl->assign('bookLink', $link); } $content = $tmpl->result(); return self::mail($book->get('mail'), $subject, $content, $replyTo); }
function sendSummary() { $userMail = Mailer::mailFromUser('mail'); if (!$userMail) { return false; } $userMail = stripslashes($userMail); $mailText = 'Hallo,' . "\n" . 'hier eine Zusammenfassung aller Bücher, die mit deiner E-Mailadresse angeboten werden.'; $books = new UsersBooks($userMail); $mailText .= $books->toString(); return Mailer::mail($userMail, 'Deine Angebote', $mailText); }
* along with this program. If not, see <http://www.gnu.org/licenses/>. */ $books = ''; require_once 'mysql_conn.php'; if (isset($_POST['subject'])) { require_once 'books/UsersBooks.php'; require_once 'tools/Mailer.php'; $subject = stripslashes($_POST['subject']); $text = stripslashes($_POST['text']); $query = 'select distinct mail from books'; $result = mysql_query($query); $user_number = mysql_num_rows($result); $sent_mails = 0; while ($mail_row = mysql_fetch_row($result)) { $mail = $mail_row[0]; $bookList = new UsersBooks($mail); $books = $bookList->toString(); $mail_text = $text . $books; $success = Mailer::mail($mail, $subject, $mail_text); if ($success) { $sent_mails++; } } header('Location: admin_mail.php?sent_mails=' . $sent_mails . '&user_number=' . $user_number); } include 'header.php'; ?> <div class="menu"><span><a href="admin.php">← Zurück zur Administrationsübersicht</a></span></div>