Mod Sürüm: 1.0.3
Mod linki: http://www.phpbb.com/phpBB/viewtopic.php?t=398193
Mod işlevi: Bu mod, siteye eklenen uzun adresleri otomatik olarak 60 karakter oranına kısaltır...
Türkçeleştirilecek dosya: yok
Kurulum: 2 dakika veya daha kısa
Diğer benzerlerinden üstünlüğü: phpBB validated olması
Kullanılan sistemler: Yakusha
- Kod: Tümünü seç
##############################################################
## 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<a href=\"\\2\" target=\"_blank\">\\2</a>", $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<a href=\"\\2\" target=\"_blank\">\\2</a>\\3";
$patterns[] = "#(^|[\n ])([\w]+?://[" . $url_meat . "]{" . $prefix_length . "})([" . $url_meat . "]+)([" . $url_meat . "]{" . $suffix_length . "})($|[^" . $url_meat . "])#is";
$replacements[] = "\\1<a href=\"\\2\\3\\4\" target=\"_blank\">\\2...\\4</a>\\5";
$ret = preg_replace($patterns, $replacements, $ret);
#
#-----[ FIND ]------------------------------------------
#
$ret = preg_replace("#(^|[\n ])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $ret);
#
#-----[ REPLACE WITH ]------------------------------------------
#
$patlazy[] = "#(^|[\n ])((www|ftp)\.[" . $url_meat . "]{1," . $max_url_length . "})($|[^" . $url_meat . "])#is";
$replazy[] = "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>\\4";
$patlazy[] = "#(^|[\n ])((www|ftp)\.[" . $url_meat . "]{" . $prefix_length . "})([" . $url_meat . "]+)([" . $url_meat . "]{" . $suffix_length . "})($|[^" . $url_meat . "])#is";
$replazy[] = "\\1<a href=\"http://\\2\\4\\5\" target=\"_blank\">\\2...\\5</a>\\6";
$ret = preg_replace($patlazy, $replazy, $ret);
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM