[外掛]Local Link 變更連結開啟視窗

MODs Released by Other phpbb Sites
非官方認證通過之 MOD ,或許有安全性之疑慮,所有問題由原發表者回覆!

版主: 版主管理群

主題已鎖定
頭像
sisomy
星球公民
星球公民
文章: 39
註冊時間: 2002-09-11 22:19
聯繫:

[外掛]Local Link 變更連結開啟視窗

文章 sisomy »

Local Links 1.1.1

來源:PHPBB官方網站
討論區


一般在BBCODE的URL連結位置\r
都是開啟新視窗
這個模組可以自己進行辨識
如果連結位置是自己的網址
會開啟在同一個視窗
如果連結網址不是自己的網站
那就會以新的視窗來開啟
因為我的論壇是框在框架裡面\r
所以找到這個我認為很好用\r
特別貼上來給有需要的朋友

我自己PHPBB2.0.3和2.0.6的論壇都可以裝

代碼: 選擇全部

## EasyMod 0.0.7 compliant
############################################################## 
## MOD Title: Local Links
## MOD Author: netclectic < adrian@netclectic.com > Adrian Cockburn - http://www.netclectic.com 
## MOD Description: This MOD will cause any local URLs (i.e. www.YOURDOMAIN.com) posted to your 
## board to open in the same window instead of in a new window, ( i.e. _self instead of _blank ). 
## This does not effect external URLs. Might not be to your liking if you do not have your own domain name.
## MOD Version: 1.1.1
## 
## Installation Level: easy
## Installation Time: 5 Minutes 
## Files To Edit: (2) includes/bbcode.php, templates/subSilver/bbcode.tpl
## Included Files: n/a
############################################################## 
## For Security Purposes, Please Check: http://www.phpbb.com/mods/downloads/ for the 
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code 
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered 
## in our MOD-Database, located at: http://www.phpbb.com/mods/downloads/ 
############################################################## 
## Author Notes: 
##
############################################################## 
## MOD History: 
## 
##        1.1.1 - Oops! Minor alterations to mod template.
##        1.1.0 - Confirmed with 2.0.4. Updated to be EasyMod compliant.
##        1.0.3 - Aarrgghhh! Regular expressions!!!.
##        1.0.2 - Fixed small bug in script - .
##        1.0.1 - Fixed some dodgy regular expressions.
##        1.0.0 - Original release.
############################################################## 
## 在增加這個模組之前,請先進行備份\r
############################################################## 
#
#-----[ 打開 ]------------------------------------------
#
includes/bbcode.php

#
#-----[ 找到 ]------------------------------------------
#

代碼: 選擇全部

$bbcode_tpl['url1'] = str_replace('{URL}', '\\\1\\\2', $bbcode_tpl['url']);
2.0.6是\r

代碼: 選擇全部

$bbcode_tpl['url1'] = str_replace('{URL}', '\\\1', $bbcode_tpl['url']);
#
#-----[ 在之前增加 ]------------------------------------------
#

代碼: 選擇全部

    // MOD LOCAL URL BEGIN 
	$bbcode_tpl['url_local1'] = str_replace('{URL}', '\\\1\\\2\\\3', $bbcode_tpl['url_local']);
\n	$bbcode_tpl['url_local1'] = str_replace('{DESCRIPTION}', '\\\1\\\2\\\3', $bbcode_tpl['url_local1']);

	$bbcode_tpl['url_local2'] = str_replace('{URL}', 'http://\\\1\\\2', $bbcode_tpl['url_local']);
	$bbcode_tpl['url_local2'] = str_replace('{DESCRIPTION}', '\\\1\\\2', $bbcode_tpl['url_local2']);

	$bbcode_tpl['url_local3'] = str_replace('{URL}', '\\\1\\\2\\\3', $bbcode_tpl['url_local']);
	$bbcode_tpl['url_local3'] = str_replace('{DESCRIPTION}', '\\\4', $bbcode_tpl['url_local3']);
	
	$bbcode_tpl['url_local4'] = str_replace('{URL}', 'http://\\\1\\\2', $bbcode_tpl['url_local']);
	$bbcode_tpl['url_local4'] = str_replace('{DESCRIPTION}', '\\\3', $bbcode_tpl['url_local4']);
    // MOD LOCAL URL END 
#
#-----[ 找到 ]------------------------------------------
#

代碼: 選擇全部

	// [img]image_url_here[/img] code..
	// This one gets first-passed..
\n#
#-----[ 在之前增加 ]------------------------------------------
#

代碼: 選擇全部

    // MOD LOCAL URL BEGIN 
    // do any local urls first... 
    // [url]xxxx://www.phpbb.com[/url] code.. 
	$local_patterns[1] = "#\[url\]([a-z]+?://){1}(".$_SERVER["SERVER_NAME"].")([a-z0-9\-\.,\?!%\*_\#:;~\\\&$@\/=\+]*)\[/url\]#si";
	$local_replacements[1] = $bbcode_tpl['url_local1'];                       

	// [url]www.phpbb.com[/url] code.. (no xxxx:// prefix).
	$local_patterns[2] = "#\[url\](".$_SERVER["SERVER_NAME"].")([a-z0-9\-\.,\?!%\*_\#:;~\\\&$@\/=\+]*)\[/url\]#si";
	$local_replacements[2] = $bbcode_tpl['url_local2'];

	// [url=xxxx://www.phpbb.com]phpBB[/url] code..
	$local_patterns[3] = "#\[url=([a-z]+?://){1}(".$_SERVER["SERVER_NAME"].")([a-z0-9\-\.,\?!%\*_\#:;~\\\&$@\/=\+]*)\](.*?)\[/url\]#si";
	$local_replacements[3] = $bbcode_tpl['url_local3'];

	// [url=www.phpbb.com]phpBB[/url] code.. (no xxxx:// prefix).
	$local_patterns[4] = "#\[url=(".$_SERVER["SERVER_NAME"].")([a-z0-9\-\.,\?!%\*_\#:;~\\\&$@\/=\+]*)\](.*?)\[/url\]#si";
	$local_replacements[4] = $bbcode_tpl['url_local4'];
    
    $text = preg_replace($local_patterns, $local_replacements, $text); 
    // now with the local urls done, it's safe to do any external urls 
    // MOD LOCAL URL END 
#
#-----[ 找到 ]------------------------------------------
#

代碼: 選擇全部

// matches an "xxxx://yyyy" URL at the start of a line, or after a space. 
#
#-----[ 在之前增加 ]------------------------------------------
#

代碼: 選擇全部

// MOD LOCAL URL BEGIN
// match a local URL and replace with a target="_self" href 
$ret = preg_replace("#([
 ])([a-z]+?)://(".$_SERVER["SERVER_NAME"].")((?:/[^\t <

]*)?)#i", "\\\1<a href=\"\\\2://\\\3\\\4\" target=\"_self\">\\\2://\\\3\\\4</a>", $ret); 
$ret = preg_replace("#([
 ])(".$_SERVER["SERVER_NAME"].")((?:/[^\t <

]*)?)#i", "\\\1<a href=\"http://\\\2\\\3\" target=\"_self\">\\\2\\\3</a>", $ret);
// MOD LOCAL URL END 

#
#-----[ 打開 ]------------------------------------------
#
templates/subSilver/bbcode.tpl

#
#-----[ 找到 ]------------------------------------------
#

代碼: 選擇全部

<!-- BEGIN url --><a href="{URL}" target="_blank" class="postlink">{DESCRIPTION}</a><!-- END url --> 
#
#-----[ 在之後增加 ]------------------------------------------
#

代碼: 選擇全部

<!-- BEGIN url_local --><a href="{URL}" target="_self" class="postlink">{DESCRIPTION}</a><!-- END url_local -->
#
#-----[ 存檔並上傳兩個檔案 /完工 ]------------------------------------------
#
# EoM
主題已鎖定

回到「非官方認證外掛」