public function InsertAndSendMail() { $quotedAuthor = trim($_POST['mail']); $quotedTitle = trim($_POST['title']); $isbn = Isbn::stringFromPost(); $year = (int) trim($_POST['year']); $price = (double) str_replace(',', '.', $_POST['price']); $quotedDescription = $_POST['desc']; $key = KeyGenerator::genKey(); $query = 'insert into books' . ' (author, title, year, price, isbn, description, mail, auth_key' . ', created,expires)' . ' values (' . '"' . $quotedAuthor . '"' . ', "' . $quotedTitle . '"' . ', "' . $year . '"' . ', "' . $price . '"' . ', "' . $isbn . '"' . ', "' . $quotedDescription . '"' . ', "' . $this->getMail() . '"' . ', "' . $key . '"' . ', now()' . ', date_add(now(), interval 45 day)' . ')'; mysql_query($query); $book_id = mysql_insert_id(); $this->selectableCategories->setBookId($book_id); $this->selectableCategories->update(); $subject = ''; $message = 'Mit deiner E-Mailadresse wurde das unten stehende Buch angeboten. Hebe diese E-Mail auf, um das Angebot später ändern und löschen zu können.'; Mailer::send($book_id, $subject, $message); $searches = new Searches(); if ($searches->areActivated()) { $author = stripslashes($quotedAuthor); $title = stripslashes($quotedTitle); $description = stripslashes($quotedDescription); $searches->bookAdded($book_id, $author, $title, $description); } header('Location: book.php?id=' . $book_id . '&key=' . $key . '&new=1'); exit; }
function testGenKey() { $key1 = KeyGenerator::genKey(); $key2 = KeyGenerator::genKey(); $this->assertNotEquals($key1, $key2); }
public function addSearch($search, $mail) { $key = KeyGenerator::genKey(); $query = 'insert into searches' . ' (search, mail, life_counter, auth_key) values' . ' ("' . $search . '"' . ', "' . $mail . '"' . ', 100 + (select count(*) from books)' . ', "' . $key . '");'; mysql_query($query); }