diff options
author | ArthurHoaro <arthur@hoa.ro> | 2016-11-28 18:24:15 +0100 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2016-12-12 03:03:12 +0100 |
commit | d592daea8343bb4dfecff5d97e93699581ccc58c (patch) | |
tree | d508b902b3aba45795fafe16e0b921ac5ea7c4c4 /application/LinkUtils.php | |
parent | c3dfd8995921083ff7250c25d0b6ab1184b91aff (diff) | |
download | Shaarli-d592daea8343bb4dfecff5d97e93699581ccc58c.tar.gz Shaarli-d592daea8343bb4dfecff5d97e93699581ccc58c.tar.zst Shaarli-d592daea8343bb4dfecff5d97e93699581ccc58c.zip |
Add a persistent 'shorturl' key to all links
All existing link will keep their permalinks.
New links will have smallhash generated with date+id.
The purpose of this is to avoid collision between links due to their creation date.
Diffstat (limited to 'application/LinkUtils.php')
-rw-r--r-- | application/LinkUtils.php | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/application/LinkUtils.php b/application/LinkUtils.php index 9d9ae3cb..cf58f808 100644 --- a/application/LinkUtils.php +++ b/application/LinkUtils.php | |||
@@ -169,3 +169,16 @@ function space2nbsp($text) | |||
169 | function format_description($description, $redirector = '', $indexUrl = '') { | 169 | function format_description($description, $redirector = '', $indexUrl = '') { |
170 | return nl2br(space2nbsp(hashtag_autolink(text2clickable($description, $redirector), $indexUrl))); | 170 | return nl2br(space2nbsp(hashtag_autolink(text2clickable($description, $redirector), $indexUrl))); |
171 | } | 171 | } |
172 | |||
173 | /** | ||
174 | * Generate a small hash for a link. | ||
175 | * | ||
176 | * @param DateTime $date Link creation date. | ||
177 | * @param int $id Link ID. | ||
178 | * | ||
179 | * @return string the small hash generated from link data. | ||
180 | */ | ||
181 | function link_small_hash($date, $id) | ||
182 | { | ||
183 | return smallHash($date->format(LinkDB::LINK_DATE_FORMAT) . $id); | ||
184 | } | ||