From 501b26ef4cc1e36be6ceb994b3571eb0eff964e6 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Fri, 19 Feb 2010 03:21:07 +0100 Subject: some changes --- paste/include/storage/FileStorage.php | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'paste/include/storage/FileStorage.php') 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) -- cgit v1.2.3