diff --git a/inc/html.php b/inc/html.php index 5903633..ae7520d 100644 --- a/inc/html.php +++ b/inc/html.php @@ -380,16 +380,16 @@ function sBool($val){ // Internal functions ------------------------------- - function _linkifyTweet_link($a, $b, $c, $d){ - $url = stripslashes($a); - $end = stripslashes($d); - return "" . (strlen($url) > 25 ? substr($url, 0, 24) . "..." : $url) . "" . $end; + function _linkifyTweet_link($m){ + $url = stripslashes($m[1]); + $end = stripslashes($m[4]); + return "" . (strlen($url) > 25 ? substr($url, 0, 24) . "..." : $url) . "" . $end; } - function _linkifyTweet_at($a, $b){ - return "@" . $a . ""; + function _linkifyTweet_at($m){ + return "@" . $m[1] . ""; } - function _linkifyTweet_hashtag($a, $b){ - return "#" . $a . ""; + function _linkifyTweet_hashtag($m){ + return "#" . $m[1] . ""; } function linkifyTweet($str, $linksOnly = false){ // Look behind (it kinda sucks, no | operator) @@ -400,24 +400,18 @@ function linkifyTweet($str, $linksOnly = false){ // Expression $html = preg_replace_callback( "/$lookbehind\b(((https?:\/\/)|www\.).+?)(([!?,.\"\)]+)?(\s|$))/", - function ($m) { - return _linkifyTweet_link($m[1], $m[2], $m[3], $m[4]); - }, + '_linkifyTweet_link', $str ); if(!$linksOnly){ $html = preg_replace_callback( "/\B\@([a-zA-Z0-9_]{1,20}(\/\w+)?)/", - function ($m) { - return _linkifyTweet_at($m[1], $m[2]); - }, + '_linkifyTweet_at', $html ); $html = preg_replace_callback( "/\B\#([\pL|0-9|_]+)/u", - function ($m) { - return _linkifyTweet_hashtag($m[1], $m[2]); - }, + '_linkifyTweet_hashtag', $html ); } @@ -544,4 +538,4 @@ function getDaysInMonth($month, $year){ } } return $d; - } \ No newline at end of file + }