diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2009-12-11 03:55:30 +0100 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2009-12-11 03:55:30 +0100 |
commit | e1f7f69c1986f79464bc9d7d465ea8c5fcd4289e (patch) | |
tree | 79091165eaf1c74359ce51143a6f2805d2b32a3b /paste/include | |
parent | 25d090f3acfbb099cca6979fb4faffc272358c84 (diff) | |
download | rafb-nopaste-e1f7f69c1986f79464bc9d7d465ea8c5fcd4289e.tar.gz rafb-nopaste-e1f7f69c1986f79464bc9d7d465ea8c5fcd4289e.tar.xz rafb-nopaste-e1f7f69c1986f79464bc9d7d465ea8c5fcd4289e.zip |
dessicion if store markuped text or plain text now at StorageEngines
Diffstat (limited to 'paste/include')
-rw-r--r-- | paste/include/storage/FileStorage.php | 4 | ||||
-rw-r--r-- | paste/include/storage/MysqlStorage.php | 30 | ||||
-rw-r--r-- | paste/include/storage/StorageEngine.php | 2 |
3 files changed, 21 insertions, 15 deletions
diff --git a/paste/include/storage/FileStorage.php b/paste/include/storage/FileStorage.php index 09b222f..77cf0af 100644 --- a/paste/include/storage/FileStorage.php +++ b/paste/include/storage/FileStorage.php @@ -42,10 +42,12 @@ class FileStorage extends StorageEngine $this->storage_path = $path; } - public function setContent($content) + public function setContent($content, $language, $nick, $description) { global $config; + $content = PastifyText($content, $language, $description); + do { $filename = sha1(date('r') . rand(1000, getrandmax())); } while (file_exists(realpath($storage_path . '/' , $filename))); diff --git a/paste/include/storage/MysqlStorage.php b/paste/include/storage/MysqlStorage.php index d15de55..f33db64 100644 --- a/paste/include/storage/MysqlStorage.php +++ b/paste/include/storage/MysqlStorage.php @@ -51,8 +51,16 @@ class MysqlStorage extends StorageEngine $this->table = $table; if (! $this->mysql->query("CREATE TABLE IF NOT EXISTS $table ( pid VARCHAR(40) PRIMARY KEY, +nick VARCHAR(255), +language VARCHAR(40), content MEDIUMTEXT, -FULLTEXT INDEX (content) +description TEXT, +remote VARCHAR(15), +time TIMESTAMP, +FULLTEXT INDEX (content), +FULLTEXT INDEX (description), +INDEX (language), +INDEX (nick) );")) { header('HTTP/1.0 503 Service Unavailable'); @@ -67,25 +75,21 @@ FULLTEXT INDEX (content) $this->mysql->close(); } - public function setContent($content) + public function setContent($content, $language, $nick, $description) { $name = sha1(date('r') . rand(1000, getrandmax())); - - if ($config['short_results_path']) { - $urlbase = $config['short_results_path']; - } else { - $urlbase = $config['site_domain'] . $config['site_path'] . '/' . $config['results_dir']; - } - $content = $this->prepareContent($name, $urlbase . 'get.php?id=' . $name, $content); - if ($stmt = $this->mysql->prepare( - 'INSERT INTO ? (pid, content) VALUES (?, ?)')) { + 'INSERT INTO ' . $this->table . ' (pid, nick, language, content, description, remote) VALUES (?, ?, ?, ?, ?, ?)')) { /* bind parameters for markers */ - $stmt->bind_param("sb", $name, $content); + $stmt->bind_param('ssssss', $name, $nick, $language, $content, $description, $_SERVER["REMOTE_ADDR"]); /* execute query */ - $stmt->execute(); + if (!$stmt->execute()) { + header('HTTP/1.0 503 Service Unavailable'); + die('MySQL Error (' . $this->mysql->errno . ') ' . + $this->mysql->error); + } $stmt->close(); } diff --git a/paste/include/storage/StorageEngine.php b/paste/include/storage/StorageEngine.php index e1668e5..32eefdd 100644 --- a/paste/include/storage/StorageEngine.php +++ b/paste/include/storage/StorageEngine.php @@ -34,7 +34,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. abstract class StorageEngine { - abstract public function setContent($content); + abstract public function setContent($content, $language, $nick, $description); public function generateToken($name) { |