summaryrefslogtreecommitdiffstats
path: root/paste/include
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2010-02-19 03:21:07 +0100
committerAlexander Sulfrian <alexander@sulfrian.net>2010-02-19 03:21:07 +0100
commit501b26ef4cc1e36be6ceb994b3571eb0eff964e6 (patch)
tree116f7e592ee74034c83d4ffb202ae72ba7b8dd68 /paste/include
parentff117414b781ac8bcfa512001af252ab44d61592 (diff)
downloadrafb-nopaste-501b26ef4cc1e36be6ceb994b3571eb0eff964e6.tar.gz
rafb-nopaste-501b26ef4cc1e36be6ceb994b3571eb0eff964e6.tar.xz
rafb-nopaste-501b26ef4cc1e36be6ceb994b3571eb0eff964e6.zip
some changes
Diffstat (limited to 'paste/include')
-rw-r--r--paste/include/storage/FileStorage.php29
-rw-r--r--paste/include/storage/MysqlStorage.php13
2 files changed, 34 insertions, 8 deletions
diff --git a/paste/include/storage/FileStorage.php b/paste/include/storage/FileStorage.php
index 057b5de..5ee2b77 100644
--- a/paste/include/storage/FileStorage.php
+++ b/paste/include/storage/FileStorage.php
@@ -46,27 +46,42 @@ class FileStorage extends StorageEngine
{
global $config;
- $content = PastifyText($content, $language, $description);
-
do {
$filename = sha1(date('r') . rand(1000, getrandmax()));
- } while (file_exists(realpath($storage_path . '/' , $filename)));
+ } while (file_exists($this->storage_path . '/' . $filename));
if ($config['short_results_path']) {
$urlbase = $config['short_results_path'];
} else {
- $urlbase = $config['site_domain'] . $config['site_path'] . '/' . $config['results_dir'];
+ $urlbase = $config['site_domain'] . $config['site_path'] . $this->storage_path;
}
- $content = $this->prepareContent($filename, $urlbase, $content);
$filename = $filename . ".html";
+ $get_url = $config['site_domain'] . $config['site_path'] . 'get.php?p=' . $filename;
+ $remove_url = $config['site_domain'] . $config['site_path'] . 'remove.php?p=' . $filename . '&t=' . $this->generateToken($filename);
+ $content = PastifyText($content, $language, $description, $get_url, $remove_url);
+
// write content
- $outfile = realpath($storage_path . '/' , $filename);
+ $outfile = $this->storage_path . $filename;
$fp = fopen($outfile, "w");
fwrite($fp, $content);
fclose($fp);
- return $pasteUrl;
+ return $get_url;
+ }
+
+ public function getContent($pid)
+ {
+ global $config;
+
+ if ($config['short_results_path']) {
+ $urlbase = $config['short_results_path'];
+ } else {
+ $urlbase = $config['site_domain'] . $config['site_path'] . $this->storage_path;
+ }
+
+ header('Location: ' . $urlbase . $pid);
+ exit;
}
public function delContent($pid)
diff --git a/paste/include/storage/MysqlStorage.php b/paste/include/storage/MysqlStorage.php
index 5dd24c3..bd532b5 100644
--- a/paste/include/storage/MysqlStorage.php
+++ b/paste/include/storage/MysqlStorage.php
@@ -76,6 +76,8 @@ INDEX (nick)
public function setContent($content, $language, $nick, $description)
{
+ global $config;
+
$name = sha1(date('r') . rand(1000, getrandmax()));
if ($stmt = $this->mysql->prepare(
'INSERT INTO ' . $this->table . '
@@ -94,10 +96,17 @@ INDEX (nick)
$stmt->close();
}
+
+ if (isset($config['short_results_path']))
+ return $config['short_results_path'] . $pid;
+
+ return $config['site_domain'] . $config['site_path'] . 'get.php?p=' . $name;
}
public function getContent($pid)
{
+ global $config;
+
if ($stmt = $this->mysql->prepare(
'SELECT nick, language, content, description, time FROM ' . $this->table . '
WHERE pid = ? LIMIT 1'))
@@ -120,7 +129,9 @@ INDEX (nick)
$stmt->close();
- echo PastifyText($content, $lang, $description);
+ $get_url = $config['site_domain'] . $config['site_path'] . 'get.php?p=' . $pid;
+ $remove_url = $config['site_domain'] . $config['site_path'] . 'remove.php?p=' . $pid . '&t=' . $this->generateToken($pid);
+ echo PastifyText($content, $lang, $description, $get_url, $remove_url);
}
}