3 /* miniqdb - A minimalistic quote database
4 Copyright (C) 2008 Ian Weller <ianweller@gmail.com>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License along
17 with this program; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
22 // Gets args from POST
23 $quote = stripslashes_if_gpc_magic_quotes($_POST["quote"]);
26 $kaboom = explode("\r\n\r\n", $quote);
30 foreach($kaboom as $quote) {
34 // Replace IRC "<" and ">" characters with the HTML equivalent.
35 // Then strip newlines from the top and bottom of the quote.
36 $quote_lt = ereg_replace('<', '<' , $quote);
37 $quote_gt = ereg_replace('>', '>' , $quote_lt);
38 $quote_lb = trim($quote_gt);
40 // Insert into database as new. We leave out ID number cause the
41 // database will autoincrement that field by itself.
43 $st = $db->prepare('INSERT INTO miniqdb (epoch,quote) VALUES (?,?)');
44 $st->execute(array(date('U'), $quote_lb));
45 $ids[] = $db->lastInsertId();
49 $qcount = count($ids);
50 echo "<p>$qcount quotes posted</p>";
51 echo "<p>The following $qcount quotes were added:</p>";
52 foreach($ids as $id) {
53 $idstrs[] = "<a href=\"quote.php?id=$id\">$id</a>";
55 $quotes = implode(' ', $idstrs);
56 echo "<p>$quotes</p>";
57 echo "<p><a href=\"index.php\">Go back to the QDB</a></p>";