Beispiel #1
0
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);
}
 function testMailFromUser()
 {
     $index = 'mail';
     $_POST[$index] = 'juser';
     $result = Mailer::mailFromUser($index);
     $this->assertNotNull($result, 'Simple name not accepted.');
     unset($_POST[$index]);
     $_GET[$index] = 'juser';
     $result = Mailer::mailFromUser($index);
     $this->assertNotNull($result, 'From $_GET array not accepted.');
     $_POST[$index] = 'juser1';
     $result = Mailer::mailFromUser($index);
     $this->assertNotNull($result, "Number not accepted.");
     $_POST[$index] = '*****@*****.**';
     $result = Mailer::mailFromUser($index);
     $this->assertNotNull($result, "Domain not accepted.");
     $_POST[$index] = "mail@example.com\nTo: spam@example.com";
     $result = Mailer::mailFromUser($index);
     $this->assertNull($result, 'new line accepted');
 }
Beispiel #3
0
 /**
  * Checks POST data and sends E-Mail, if everything is correct.
  * @return bool true, if mail variable doesn't contain an @.
  */
 public function sendMailIfRequested()
 {
     /*
      * $_POST['name'] should contain a mail address.
      * It is named 'name' to trick robots.
      */
     if (!isset($_POST['name'])) {
         return false;
     }
     $user_mail = stripslashes(Mailer::mailFromUser('name'));
     if (!strstr($user_mail, '@')) {
         return true;
     }
     require_once 'tools/Mailer.php';
     $subject = 'Anfrage: ';
     $message = 'Es hat jemand mit der E-Mailadresse "' . $user_mail . '" Interesse für das unten stehende Buch bekundet.';
     if (isset($_POST['user_text']) && $_POST['user_text']) {
         $message .= ' Folgende Nachricht wurde mitgesandt:' . "\n\n";
         $message .= stripslashes($_POST['user_text']) . "\n";
     }
     $booked = Mailer::send($this->bookId, $subject, $message, $user_mail);
     header('Location: book.php?id=' . $this->bookId . '&booked=' . $booked);
     exit;
 }
Beispiel #4
0
function import_book($bookString, Template $tmpl)
{
    $labels = array('Autor', 'Titel', 'Preis', 'Erscheinungsjahr', 'ISBN', 'Beschreibung');
    $indices = array('author', 'title', 'price', 'year', 'isbn', 'description');
    $bookString = trim($bookString);
    $bookLines = split("\n", $bookString, sizeof($labels));
    for ($i = 0; $i < sizeof($labels); $i++) {
        list($label, $value) = split(':', $bookLines[$i], 2);
        if (trim($label) != $labels[$i]) {
            $value = '';
        }
        $value = Parser::text2html(stripslashes(trim($value)));
        $tmpl->assign($indices[$i], $value);
    }
}
$usermail = Parser::text2html(stripslashes(Mailer::mailFromUser('mail')));
if (isset($_POST['book_data'])) {
    $tmpl = Template::fromFile('view/add_form.html');
    import_book($_POST['book_data'], $tmpl);
    if (isset($_POST['mail'])) {
        $tmpl->assign('mail', $usermail);
    }
    $selectableCategories = new SelectableCategories();
    $categoryString = implode(' ', $selectableCategories->createSelectArray());
    $tmpl->assign('categories', $categoryString);
} else {
    $tmpl = Template::fromFile('view/import.html');
    if (isset($_GET['mail'])) {
        $mailTmpl = $tmpl->addSubtemplate('mail');
        $mailTmpl->assign('mail', $usermail);
    }
Beispiel #5
0
 private function getMail()
 {
     if ($this->mail === null) {
         $this->mail = Mailer::mailFromUser('author');
     }
     return $this->mail;
 }
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
require_once 'books/SearchKey.php';
require_once 'notification/Searches.php';
require_once 'tools/Mailer.php';
$searchKey = new SearchKey();
if (!$searchKey->isGiven()) {
    header('Location: ./');
}
$mail = Mailer::mailFromUser('mail');
if ($mail == null) {
    $mail = Mailer::mailFromUser('name');
}
if ($mail) {
    $searches = new Searches();
    $searches->addSearch($searchKey->asText(), $mail);
    header('Location: ./?search=' . urlencode($searchKey->asText()) . '&searchSaved=1');
}
$tmpl = Template::fromFile("view/save_search.html");
$tmpl->assign('searchKey', $searchKey->asHtml());
$tmpl->assign('urlSearchKey', urlencode($searchKey->asHtml()));
$output = new Output();
$output->send($tmpl->result());