summaryrefslogtreecommitdiffstats
path: root/paste
diff options
context:
space:
mode:
Diffstat (limited to 'paste')
-rw-r--r--paste/include/storage/FileStorage.php11
-rw-r--r--paste/include/storage/MysqlStorage.php15
-rw-r--r--paste/include/storage/StorageEngine.php1
3 files changed, 27 insertions, 0 deletions
diff --git a/paste/include/storage/FileStorage.php b/paste/include/storage/FileStorage.php
index 77cf0af..057b5de 100644
--- a/paste/include/storage/FileStorage.php
+++ b/paste/include/storage/FileStorage.php
@@ -68,6 +68,17 @@ class FileStorage extends StorageEngine
return $pasteUrl;
}
+
+ public function delContent($pid)
+ {
+ $filename = realpath($this->storage_path . $pid);
+ if (!empty($filename) && file_exists($filename)) {
+ if (!@unlink($filename)) {
+ header('HTTP/1.0 503 Service Unavailable');
+ die('Failed to remove ' . $filename);
+ }
+ }
+ }
}
?>
diff --git a/paste/include/storage/MysqlStorage.php b/paste/include/storage/MysqlStorage.php
index 49af59e..5dd24c3 100644
--- a/paste/include/storage/MysqlStorage.php
+++ b/paste/include/storage/MysqlStorage.php
@@ -123,6 +123,21 @@ INDEX (nick)
echo PastifyText($content, $lang, $description);
}
}
+
+ public function delContent($pid)
+ {
+ if ($stmt = $this->mysql->prepare('DELETE 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);
+ }
+ }
+ }
}
?>
diff --git a/paste/include/storage/StorageEngine.php b/paste/include/storage/StorageEngine.php
index 8cf697c..db6e34b 100644
--- a/paste/include/storage/StorageEngine.php
+++ b/paste/include/storage/StorageEngine.php
@@ -36,6 +36,7 @@ abstract class StorageEngine
{
abstract public function setContent($content, $language, $nick, $description);
abstract public function getContent($pid);
+ abstract public function delContent($pid);
public function generateToken($name)
{