From d61ce7709a992f9c1798fd82c906fd83fee4b635 Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Tue, 21 Feb 2012 18:07:30 +0100 Subject: [PATCH] SN addon, only work with the 1st 2*max_char chars during preparation of denting --- statusnet/statusnet.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index 5d893d6b..2972f662 100755 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -416,8 +416,12 @@ function statusnet_post_hook(&$a,&$b) { require_once('include/bbcode.php'); $dent = new StatusNetOAuth($api,$ckey,$csecret,$otoken,$osecret); - $max_char = $dent->get_maxlength(); // max. length for a dent - $tmp = $b['body']; + $max_char = $dent->get_maxlength(); // max. length for a dent + // we will only work with up to two time the length of the dent + // we can later send to StatusNet. This way we can "gain" some + // information during shortening of potential links but do not + // shorten all the links in a 200000 character long essay. + $tmp = substr($b['body'], 0, 2*$max_char); // if [url=bla][img]blub.png[/img][/url] get blub.png $tmp = preg_replace( '/\[url\=(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)\]\[img\](\\w+.*?)\\[\\/img\]\\[\\/url\]/i', '$2', $tmp); // $tmp = preg_replace( '/\[url\=(\w+.*?)\]\[img\](\w+.*?)\[\/img\]\[\/url\]/i', '$2', $tmp); -- 2.39.5