summaryrefslogtreecommitdiffstats
path: root/paste/include
diff options
context:
space:
mode:
Diffstat (limited to 'paste/include')
-rw-r--r--paste/include/storage/MysqlStorage.php36
-rw-r--r--paste/include/storage/StorageEngine.php1
2 files changed, 34 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();
+ }
+ }
}
?>
diff --git a/paste/include/storage/StorageEngine.php b/paste/include/storage/StorageEngine.php
index 32eefdd..b0030d0 100644
--- a/paste/include/storage/StorageEngine.php
+++ b/paste/include/storage/StorageEngine.php
@@ -35,6 +35,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
abstract class StorageEngine
{
abstract public function setContent($content, $language, $nick, $description);
+ abstract public function getContent($pid);
public function generateToken($name)
{