summaryrefslogtreecommitdiffstats
path: root/paste/include/storage/MysqlStorage.php
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2009-12-11 05:23:56 +0100
committerAlexander Sulfrian <alexander@sulfrian.net>2009-12-11 05:23:56 +0100
commit8b2b99cc812644d30e1c4d3f96c2eafc7c21738a (patch)
tree71198f230741554ac5ba69882a1ef90d0863a9c3 /paste/include/storage/MysqlStorage.php
parente1f7f69c1986f79464bc9d7d465ea8c5fcd4289e (diff)
downloadrafb-nopaste-8b2b99cc812644d30e1c4d3f96c2eafc7c21738a.tar.gz
rafb-nopaste-8b2b99cc812644d30e1c4d3f96c2eafc7c21738a.tar.xz
rafb-nopaste-8b2b99cc812644d30e1c4d3f96c2eafc7c21738a.zip
added getContent to StorageEngine
Diffstat (limited to 'paste/include/storage/MysqlStorage.php')
-rw-r--r--paste/include/storage/MysqlStorage.php36
1 files changed, 33 insertions, 3 deletions
diff --git a/paste/include/storage/MysqlStorage.php b/paste/include/storage/MysqlStorage.php
index f33db64..fa8a9de 100644
--- a/paste/include/storage/MysqlStorage.php
+++ b/paste/include/storage/MysqlStorage.php
@@ -79,9 +79,11 @@ INDEX (nick)
{
$name = sha1(date('r') . rand(1000, getrandmax()));
if ($stmt = $this->mysql->prepare(
- 'INSERT INTO ' . $this->table . ' (pid, nick, language, content, description, remote) VALUES (?, ?, ?, ?, ?, ?)')) {
-
- /* bind parameters for markers */
+ 'INSERT INTO ' . $this->table . '
+ (pid, nick, language, content,
+ description, remote) VALUES
+ (?, ?, ?, ?, ?, ?)'))
+ {
$stmt->bind_param('ssssss', $name, $nick, $language, $content, $description, $_SERVER["REMOTE_ADDR"]);
/* execute query */
@@ -94,6 +96,34 @@ INDEX (nick)
$stmt->close();
}
}
+
+ public function getContent($pid)
+ {
+ if ($stmt = $this->mysql->prepare(
+ 'SELECT nick, language, content, description, time FROM ' . $this->table . '
+ WHERE pid = ? LIMIT 1'))
+ {
+ $stmt->bind_param('s', $pid);
+
+ /* execute query */
+ if (!$stmt->execute()) {
+ header('HTTP/1.0 503 Service Unavailable');
+ die('MySQL Error (' . $this->mysql->errno . ') ' .
+ $this->mysql->error);
+ }
+
+ $stmt->bind_result($nick, $lang, $content, $description, $time);
+
+ if (!$stmt->fetch()) {
+ header('HTTP/1.0 404 Not Found');
+ die('No such paste');
+ }
+
+ echo PastifyText($content, $lang, $description);
+
+ $shmt->close();
+ }
+ }
}
?>