From 10a9b20a5eecf6b932716cb4250a5a53214519b4 Mon Sep 17 00:00:00 2001
From: Alexander Sulfrian <alexander@sulfrian.net>
Date: Fri, 19 Feb 2010 04:07:21 +0100
Subject: fixed behaviour with short paths

---
 paste/config.php                       | 2 +-
 paste/include/storage/MysqlStorage.php | 5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/paste/config.php b/paste/config.php
index 3dee814..727952c 100644
--- a/paste/config.php
+++ b/paste/config.php
@@ -46,7 +46,7 @@ $config = array(
 	// This is the path of the URL that will be generated for sharing (allows
 	// shorter URLs to be used if you've set something up on your web server
 	// to support this.
-	// short_results_path' => 'http://www.example.net/p/'
+	'short_results_path' => 'http://' . $_SERVER["SERVER_NAME"] . '/',
 
 	// Change this to a unique value
 	'token_salt'    => 'saltsaltsalt',
diff --git a/paste/include/storage/MysqlStorage.php b/paste/include/storage/MysqlStorage.php
index bd532b5..14aefa6 100644
--- a/paste/include/storage/MysqlStorage.php
+++ b/paste/include/storage/MysqlStorage.php
@@ -98,7 +98,7 @@ INDEX (nick)
 		}
 
 		if (isset($config['short_results_path']))
-			return $config['short_results_path'] . $pid;
+			return $config['short_results_path'] . $name . '.html';
 
 		return $config['site_domain'] . $config['site_path'] . 'get.php?p=' . $name;
 	}
@@ -130,6 +130,9 @@ INDEX (nick)
 			$stmt->close();
 
 			$get_url = $config['site_domain'] . $config['site_path'] . 'get.php?p=' . $pid;
+			if (isset($config['short_results_path']))
+				$get_url = $config['short_results_path'] . $pid . '.html';
+
 			$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);
 		}
-- 
cgit v1.2.3