summaryrefslogtreecommitdiffstats
path: root/paste/include/storage/MysqlStorage.php
diff options
context:
space:
mode:
Diffstat (limited to '')
-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();
+ }
+ }
}
?>