[問題] [外掛] ed2k連結

phpBB 2 MOD Support
無論是官方或非官方認證之外掛,安裝與使用問題討論。
(發表文章請按照公告格式發表,違者砍文)

版主: 版主管理群

主題已鎖定
羅希
星球普通子民
星球普通子民
文章: 10
註冊時間: 2005-03-31 01:53

[問題] [外掛] ed2k連結

文章 羅希 »

已裝了Multiple BBCode MOD和eDoNKeY BBcode Mod了
但是只要連結中有"]"就會失效
請問要怎樣解決呢?
我看其他人的論壇都可以發表這樣的連結
謝謝!!
夜楓
星球公民
星球公民
文章: 131
註冊時間: 2003-05-16 21:19

文章 夜楓 »

你一定沒爬文........

後台把允許使用的 HTML 標籤改成b,i,u,pre,a
●架設主機作業系統:Windows XP SP2
●快速架站程式:appserv2.4.4a
●您的上網方式:Hinet 12M/1M
●phpBB2 版本:phpBB 2.0.20
羅希
星球普通子民
星球普通子民
文章: 10
註冊時間: 2005-03-31 01:53

文章 羅希 »

我爬過了....我原本就是因為用html語法
但因為覺得太長...而且一定要把"使用html語法"打開\r
所以覺得麻煩....才會想用BBcode解決
而且我也有先說是在問eDoNKeY BBcode Mod的問題喔
如果有發問不當,那就請版主刪文吧!!
skywalker
星球普通子民
星球普通子民
文章: 4
註冊時間: 2002-09-14 00:02
來自: TAICHUNG

文章 skywalker »

今天正剛好需要安裝這東西,爬到這篇文章...發現確實是有羅希提到的[的問題,如果ed link的檔名包含[],顯示會出錯。後來弟在國外找到底下這個MOD,解決了此問題,連ed2k連結檔名unicode亂碼問題都一併解決了!(作者還加入了二個小圖...同時可以顯示檔案大小)

原出處:按這裡

注意:安裝此MOD之前,記得先把其他的ed2k mod拆掉。

代碼: 選擇全部

############################################################## 
## MOD Title: eD2k Links add all Feature 
## MOD Author: Simon Moon <simon@gomp.net> (Christian Riesen) http://www.blackpearltech.com/ 
## MOD Authors: [ Oki/Mozes/Meithar/ppw ] 
## MOD Description: Makes ed2k links for files and servers clickable and adds a link for adding all files in a post at once. 
## MOD Version: 1.2.0 
## 
## Installation Level: moderate 
## Installation Time: 6 Minutes 
## Files To Edit: includes/bbcode.php 
##                viewtopic.php 
## Included Files:  images/mule_icon.gif (http://www.ed2k-it.com/forum/images/mule_icon.gif) 
##                images/ed2k-info.gif (http://www.ed2k-it.com/forum/images/ed2k-info.gif) 
## 
## Tested with phpBB Version 2.0.11 to 2.0.15 
## Forum Link: http://www.phpbb.com/phpBB/viewtopic.php?t=206016 
############################################################## 
## 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: 
## If you have already installed a ed2k hack (which you mostlikely will have) 
## check the files mentioned below anyways and change it to this version of 
## the hack. This is very important to ensure it will work properly, otherwise 
## you might have weird problems. 
## Change the line below that looks like this to have a different text: 
## $t_ed2kinsert .= "<a href='javascript:addall()'>Add ".$t_ed2k_confirmed." links to ed2k client</a> "; 
## You can for example leave away the number of files. 
############################################################## 
## MOD History: 
##    2005-05-07 - Version 1.2.0 
##       - compatible with latest ed2k link formats 
##      - friendly readable names, kB, MB 
##      - added icons 
## 
##   2004-06-27 - Version 1.1.1 
##      - Error with ' sign in filenames 
## 
##   2004-06-27 - Version 1.1.0 
##      - Javascript bug in add all, predefining of filearray 
## 
##   2004-06-27 - Version 1.0.0 
##      - First release, works fine, could use some different look 
## 
############################################################## 
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
############################################################## 
#-----[ OPEN ]----- 
# 
includes/bbcode.php 

# 
#-----[ FIND ]----- 
# 
$bbcode_tpl['url4'] = str_replace('{DESCRIPTION}', '\\\2', $bbcode_tpl['url4']); 

# 
#-----[ AFTER, ADD ]----- 
# 
// ed2k links 
$bbcode_tpl['url5'] = str_replace('{URL}', '\\\1', $bbcode_tpl['url']); 
$bbcode_tpl['url5'] = str_replace('{DESCRIPTION}', '\\\2', $bbcode_tpl['url5']); 

// ed2k links with description 
$bbcode_tpl['url6'] = str_replace('{URL}', '\\\1', $bbcode_tpl['url']); 
$bbcode_tpl['url6'] = str_replace('{DESCRIPTION}', '\\\3', $bbcode_tpl['url6']); 
// end ed2k links 

# 
#-----[ FIND ]----- 
# 
// [url=www.phpbb.com]phpBB[/url] code.. (no xxxx:// prefix). 
$patterns[] = "#\[url=((www|ftp)\.[^ \"

\t<]*?)\](.*?)\[/url\]#is"; 
$replacements[] = $bbcode_tpl['url4']; 

# 
#-----[ AFTER, ADD ]----- 
# 
// url-ed2k, name code 
$patterns[] = "#\[url=(ed2k://\|file\|.*\|\d+\|\w+\|/?)\](.*?)\[/url\]#si"; 
$replacements[] = $bbcode_tpl['url5']; 

// name code 
$patterns[] = "#\[url=(ed2k:(//)?\|server\|[\d\.]+\|\d+\|/?)\](.*?)\[/url\]#si"; 
$replacements[] = $bbcode_tpl['url6']; 
// end url-ed2k 

# 
#-----[ FIND ]----- 
# 
/** 
 * Rewritten by Nathan Codding - Feb 6, 2001. 
 * - Goes through the given string, and replaces xxxx://yyyy with an HTML <a> tag linking 
 *    to that URL 

# 
#-----[ BEFORE, ADD ]----- 
# 
// ed2k links 
// Returns a file size formatted in a more human-friendly format, rounded 
// to the nearest Gb, Mb, Kb, or byte. 

function ed2k_humanize_size ($size, $rounder = 0, $min = '') 
{ 
   $sizes   = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); 
   $rounders = array(0,   0,    0,    2,    2,    3,    3,    3,    3); 
   $ext = $sizes[0]; 
   $rnd = $rounders[0]; 

   if ($min == 'KB' && $size < 1024) 
   { 
      $size = $size / 1024; 
      $ext = 'KB'; 
      $rounder = 1; 
   } 
   else 
   { 
      for ($i=1, $cnt=count($sizes); ($i < $cnt && $size >= 1024); $i++) 
      { 
         $size = $size / 1024; 
         $ext  = $sizes[$i]; 
         $rnd  = $rounders[$i]; 
      } 
   } 

   if (!$rounder) 
   { 
      $rounder = $rnd; 
   } 

   return round($size, $rounder) . '&nbsp;' . $ext; 
} 

function ed2k_link_callback ($m) 
{ 
   $max_len = 120; 
   $href = 'href="' . $m[2] . '" class="postlink"'; 
   $size = ed2k_humanize_size($m[4]); 
   $fname = urldecode($m[3]); 

   if (strlen($fname) > $max_len) 
   { 
      $fname = substr($fname, 0, $max_len - 19) . '...' . substr($fname, -16); 
   } 
   if (preg_match('#[<>"]#', $fname)) 
   { 
      $fname = htmlspecialchars($fname); 
   } 
   // added an icon in front of link (ppw) 
   return "<img src='images/mule_icon.gif' border='0'>&nbsp;<a $href>$fname&nbsp;($size)</a>"; 
} 
// ed2k links end 

# 
#-----[ FIND ]----- 
# 
function make_clickable($text) 
{ 
   $text = preg_replace('#(script|about|applet|activex|chrome):#is', "\\\1:", $text); 

   // pad it with a space so we can match things at the start of the 1st line. 
   $ret = ' ' . $text; 
    
# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 
// ed2k file links (Meithar): 
// ed2k://|file|fileName|fileSize|fileHash|(optional params)|(optional params)|etc| 
$ret = preg_replace_callback("#(^|(?<=[^\w\"']))(ed2k://\|file\|([^\\\/\|:<>\*\?\"]+?)\|(\d+?)\|([a-f0-9]{32})\|(.*?)/?)(?![\"'])(?=([,\.]*?[\s<\[])|[,\.]*?$)#i", "ed2k_link_callback", $ret); 
// ed2k server links: 
// ed2k://|server|serverIP|serverPort 
$ret = preg_replace("#(^|(?<=[^\w\"']))(ed2k://\|server\|([\d\.]+?)\|(\d+?)\|/?)#i", "<a href=\"\\\2\" class=\"postLink\">\\\3:\\\4</a>", $ret); 
// ed2k file links end 

# 
#-----[ FIND ]----- 
# 
// Note: Only the followed chars are valid; alphanums, "-", "_" and or ".". 
$ret = preg_replace("#([
 ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)?[\w]+)#i", "\\\1<a href=\"mailto:\\\2@\\\3\">\\\2@\\\3</a>", $ret); 

// Remove our padding.. 
$ret = substr($ret, 1); 

return($ret); 
} 

# 
#-----[ AFTER, ADD ]----- 
# 
/** 
* Christian Riesen - Jun 27, 2004 
* Adds the "Add all links to ed2k client" link to the end of the post text 
*/ 
function make_addalled2k_link($text,$post_id) 
{ 
// padding 
$ret = ' ' . $text; 

// dig through the message for all ed2k links! 
// split up by "ed2k:" 
$t_ed2k_raw = explode("ed2k:",$text); 

// The first item is garbage 
unset($t_ed2k_raw[0]); 

// no need to dig through it if there are not at least 2 links! 
$t_ed2k_possibles = count($t_ed2k_raw); 
if ($t_ed2k_possibles > 1) 
{ 
unset($t_ed2k_reallinks); 
foreach ($t_ed2k_raw as $t_ed2k_raw_line) 
{ 
$t_ed2k_parts = explode("|",$t_ed2k_raw_line); 
// This looks now like this (only important parts included 
/* 
[1]=> 
string(4) "file" 
[2]=> 
string(46) "some-filename-here.txt" 
[3]=> 
string(9) "321456789" 
[4]=> 
string(32) "112233445566778899AABBCCDDEEFF11" 
*/ 

// Check the obvious things 
if (strlen($t_ed2k_parts[1]) == 4 AND $t_ed2k_parts[1] === "file" AND strlen($t_ed2k_parts[2]) > 0 AND strlen($t_ed2k_parts[4]) == 32 AND floatval($t_ed2k_parts[3]) > 0) 
{ 
// This is a true link, lets paste it together and put it in an array 
$t_ed2k_reallinks[] = "ed2k://|file|".str_replace("'","\'",$t_ed2k_parts[2])."|".$t_ed2k_parts[3]."|".$t_ed2k_parts[4]."|"; 
} 
} 

// Now lets see if we have 2 or more links 
// Only then, we do our little trick, because otherwise, it would be wasted for one link alone! 
$t_ed2k_confirmed = count($t_ed2k_reallinks); 
if ($t_ed2k_confirmed > 1) 
{ 
$t_ed2kinsert = " 
"; 
$t_ed2kinsert .= "<SCRIPT> "; 
$t_ed2kinsert .= "filearray".$post_id."=new Array; "; 
$t_ed2kinsert .= "n=0; "; 
$i = 0; 
foreach($t_ed2k_reallinks as $t_ed2klink) 
{ 
$t_ed2kinsert .= "filearray".$post_id."[".$i."]='".$t_ed2klink."'; "; 
$i++; 
} 
$t_ed2kinsert .= "iv=false; "; 
$t_ed2kinsert .= "function addfile".$post_id."(){ "; 
$t_ed2kinsert .= " var s=filearray".$post_id."[n]; "; 
$t_ed2kinsert .= " n++; "; 
$t_ed2kinsert .= " if(n==filearray".$post_id.".length && iv){ "; 
$t_ed2kinsert .= " top.clearInterval(iv); "; 
$t_ed2kinsert .= " n=0; "; 
$t_ed2kinsert .= " } "; 
$t_ed2kinsert .= " top.document.location=s; "; 
$t_ed2kinsert .= " return true; "; 
$t_ed2kinsert .= "} "; 
$t_ed2kinsert .= "function addall".$post_id."(){iv=top.setInterval('addfile".$post_id."()',250)} "; 
$t_ed2kinsert .= "</SCRIPT> "; 
//added an icon in front of link (ppw) 
$t_ed2kinsert .= "<img src='images/ed2k-info.gif' border='0'>&nbsp;<a href='javascript:addall".$post_id."()'>Add ".$t_ed2k_confirmed." links to ed2k client</a> "; 
$ret = $ret . $t_ed2kinsert; 
} 
} 

// remove padding 
$ret = substr($ret, 1); 

return($ret); 
} 
// Add all links to ed2k client end 

# 
#-----[ OPEN ]----- 
# 
viewtopic.php 

# 
#-----[ FIND ]----- 
# 
$message = make_clickable($message); 

# 
#-----[ BEFORE, ADD ]----- 
# 
$message = make_addalled2k_link($message,$postrow[$i]['post_id']); // ed2k link and add all 

#-----[ SAVE/CLOSE ALL FILES ]-----
圖片請由底下網址下載...
http://www.ed2k-it.com/forum/images/mule_icon.gif
http://www.ed2k-it.com/forum/images/ed2k-info.gif
sojoy2008
星球普通子民
星球普通子民
文章: 2
註冊時間: 2003-05-08 12:02

文章 sojoy2008 »

好象ED2K中有中文时会显示错误

有高手指点吗?
主題已鎖定

回到「外掛問題討論」