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"]);
25 // Replace IRC "<" and ">" characters with the HTML equivalent.
26 // Then strip newlines from the top and bottom of the quote.
27 $quote_lt = ereg_replace('<', '<' , $quote);
28 $quote_gt = ereg_replace('>', '>' , $quote_lt);
29 $quote_lb = trim($quote_gt);
31 // Check to make sure we have contents being put in the database, otherwise
32 // an empty quote will occur
33 if (strlen($quote_lb) <= 0) {
34 echo "<p>No quote was submitted.</p>";
39 // Insert into database as new. We leave out ID number cause the
40 // database will autoincrement that field by itself.
42 $st = $db->prepare('INSERT INTO miniqdb (epoch,quote) VALUES (?,?)');
43 $st->execute(array(date('U'), $quote_lb));
44 $id = $db->lastInsertId();
46 echo "<p>quote posted</p>";
47 echo "<p>Quote <a href=\"quote.php?id=$id\">$id</a> was just added.</p>";
48 echo "<p><a href=\"index.php\">Go back to the QDB</a></p>";