############################################################## ## MOD Title: Auto Shorten URLs ## MOD Author: nfs < mechanic@financialwebring.com > (Norbert Schlenker) http://www.financialwebring.com ## MOD Description: Automatically shortens posted URLs to 60 characters to prevent left-right scroll in message displays. ## MOD Version: 1.0.3 ## ## Installation Level: Easy ## Installation Time: 1 Minute ## Files To Edit: includes/bbcode.php ## Included Files: (N/A) ## License: http://opensource.org/licenses/gpl-license.php GNU General Public License v2 ############################################################## ## For security purposes, please check: http://www.phpbb.com/mods/ ## for the latest version of this MOD. Although MODs are checked ## before being allowed in the MODs Database there is no guarantee ## that there are no security problems within the MOD. No support ## will be given for MODs not found within the MODs Database which ## can be found at http://www.phpbb.com/mods/ ############################################################## ## Author Notes: ## ############################################################## ## MOD History: ## ## 2006-07-27 - Version 1.0.3 ## - fixed problems with bare urls at end of quotes/messages ## - leaves intact a bug in the stock code that leaves bare urls ## at the very start of a quote unclickable ## 2005-12-13 - Version 1.0.2 ## - change in 2.0.19 make_clickable() required revision ## 2005-10-14 - Version 1.0.0 ## - initial code ## ############################################################## ## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD ############################################################## # #-----[ OPEN ]------------------------------------------ # includes/bbcode.php # #-----[ FIND ]------------------------------------------ # $ret = preg_replace("#(^|[\n ])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1\\2", $ret); # #-----[ REPLACE WITH ]------------------------------------------ # $url_meat = "\w\#$%&~/.\-;:=,?@\[\]+"; $max_url_length = 60; $prefix_length = 40; $suffix_length = $max_url_length - $prefix_length - 3; // -3 for "..." in the middle $patterns[] = "#(^|[\n ])([\w]+?://[" . $url_meat . "]{1," . $max_url_length . "})($|[^" . $url_meat . "])#is"; $replacements[] = "\\1\\2\\3"; $patterns[] = "#(^|[\n ])([\w]+?://[" . $url_meat . "]{" . $prefix_length . "})([" . $url_meat . "]+)([" . $url_meat . "]{" . $suffix_length . "})($|[^" . $url_meat . "])#is"; $replacements[] = "\\1\\2...\\4\\5"; $ret = preg_replace($patterns, $replacements, $ret); # #-----[ FIND ]------------------------------------------ # $ret = preg_replace("#(^|[\n ])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1\\2", $ret); # #-----[ REPLACE WITH ]------------------------------------------ # $patlazy[] = "#(^|[\n ])((www|ftp)\.[" . $url_meat . "]{1," . $max_url_length . "})($|[^" . $url_meat . "])#is"; $replazy[] = "\\1\\2\\4"; $patlazy[] = "#(^|[\n ])((www|ftp)\.[" . $url_meat . "]{" . $prefix_length . "})([" . $url_meat . "]+)([" . $url_meat . "]{" . $suffix_length . "})($|[^" . $url_meat . "])#is"; $replazy[] = "\\1\\2...\\5\\6"; $ret = preg_replace($patlazy, $replazy, $ret); # #-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ # # EoM