Board logo

主題: [Discuz] [問題] 如何讓ED2K的連結可以在Discuz上顯示 [打印本頁]

發表人: Keitaro    時間: 2005-12-19 06:11 PM     主題: [問題] 如何讓ED2K的連結可以在Discuz上顯示

如同下面這段ED的連結

CODE:
[Copy to clipboard]
<a href="ed2k://|file|[HKG&X2][BLOOD+][11][BIG5][XVID_AAC].avi|259251344|2FCB691E3AA09406C658775309ED3787|/">[HKG&X2][BLOOD+][11][BIG5][XVID_AAC].avi</a>
在貴站還有ES都能以超連結的方式顯示


=====================================
不知道該修改哪些部份,才能讓DISCUZ支援ED2K的連結

在網路上也有找到幾個方法,不過都是以 [emule=******]ed2k://[/emule] 這種形式修改的

不像這裡還有ES一樣可以直接貼再內容就可以顯示出來

小弟目前使用2.5 SP1版本,希望各位熱心的大大可以分享一下修改的方法
發表人: Vic    時間: 2005-12-22 12:42 AM

在 include/discuzcode.php內

找postify function最後...return那一句...改成

CODE:
[Copy to clipboard]
return make_clickable($message);
在discuzcode.php最後...新增 make_clickable這功能

CODE:
[Copy to clipboard]
function make_clickable($text)
{
        // pad it with a space so we can match things at the start of the 1st line.
        $ret = ' ' . $text;

        // matches an email@domain type address at the start of a line, or after a space.
        // Note: Only the followed chars are valid; alphanums, "-", "_" and or ".".
        $ret = preg_replace("#(^|[\n ])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $ret);

        //$ret = preg_replace("#([\n ])(ed2k://\|file\|(.*)\|(\d+)\|\w+\|/?)#", "\\1<a href=\"\\2\"><font color=\"Teal\">\\3</font></a>", $ret);

        $ret = preg_replace("#([\n ])(ed2k://\|file\|(.*)\|(\d+)\|\w+\|(h=\w+\|)?/?)#", "\\1<a href=\"\\2\"><font color=\"Teal\">\\3</font></a>", $ret);

        $ret = preg_replace("#([\n ])(ed2k:(//)?\|server\|([\d\.]+)\|(\d+)\|/?)#", "\\1eD server: <a href=\"\\2\"><font color=\"Teal\">\\4 at \\5</font></a>", $ret);
       
        //$ret = preg_replace("#<a href=\"(ed2k://\|file\|(.*)\|(\d+)\|\w+\|/?)\">(.*)</a>#", "<a href=\"\\1\"><font color=\"Teal\">\\2</font></a>", $ret);

        $ret = preg_replace("#<a href=\"(ed2k://\|file\|(.*)\|(\d+)\|\w+\|(h=\w+\|)?/?)\">(.*)</a>#", "<a href=\"\\1\"><font color=\"Teal\">\\2</font></a>", $ret);

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

        return($ret);
}
就這樣...
發表人: Keitaro    時間: 2005-12-22 04:50 PM

感謝Vic兄的指導

問題已順利解決

[Keitaro 在 2005-12-22 04:52 PM 作了最後編輯]
發表人: 天驢風雲    時間: 2006-4-18 03:54 PM

請問在Discuz4.1上

怎樣才能像TWED2K直接貼ED就能以超連結的方式顯示
發表人: Vic    時間: 2006-4-20 09:36 PM


引用:
天驢風雲寫到:
請問在Discuz4.1上
怎樣才能像TWED2K直接貼ED就能以超連結的方式顯示


方法也是跟上面提到的一樣.
發表人: 天驢風雲    時間: 2006-4-26 11:42 PM

再請問Discuz4.1上的discuzcode.func.php
找不到postify function
那要怎麼改
發表人: Vic    時間: 2006-5-8 11:29 AM

sorry, 現在才看到...查看一下....在4.1, postify改成了 discuzcode  
發表人: 天驢風雲    時間: 2006-5-8 11:42 PM

用上面的方法修改後
內容會無法顯示
希望熊小能在貼一次DZ4.1的語法

[天驢風雲 在 2006-5-23 02:47 PM 作了最後編輯]
發表人: Vic    時間: 2006-5-23 02:57 PM



CODE:
[Copy to clipboard]
return $htmlon || $allowhtml ? $message : nl2br(str_replace(array("\t", '   ', '  '), array('&nbsp; &nbsp; &nbsp; &nbsp; ', '&nbsp; &nbsp;', '&nbsp;&nbsp;'), $message));
==>

CODE:
[Copy to clipboard]
return $htmlon || $allowhtml ? make_clickable($message) : nl2br(str_replace(array("\t", '   ', '  '), array('&nbsp; &nbsp; &nbsp; &nbsp; ', '&nbsp; &nbsp;', '&nbsp;&nbsp;'), make_clickable($message)));


不過在我自己測試中, 以上的方法會將文字中的space與空行remove, 所以我改成

CODE:
[Copy to clipboard]
$message = nl2br(str_replace(array("\t", '   ', '  '), array('&nbsp; &nbsp; &nbsp; &nbsp; ', '&nbsp; &nbsp;', '&nbsp;&nbsp;'), $message));
return make_clickable($message);
sorry來晚了~ @"@
發表人: 天驢風雲    時間: 2006-5-23 06:37 PM

內容顯示還是空白
如下


對不起在熊小忙著更新論壇
還來打擾
辛苦熊小了

[天驢風雲 在 2006-5-23 08:07 PM 作了最後編輯]

附件: discuzcode.func.php.txt (2006-5-23 06:37 PM, 15.9 K) / 該附件被下載次數 3
http://twed2k.org/attachment.php?aid=28958
發表人: Vic    時間: 2006-5-23 07:01 PM

天驢將你整個 include/discuzcode.php改成 discuzcode.txt再上傳上來看看吧.
發表人: Vic    時間: 2006-5-23 08:15 PM

試用附件的.

如果還是不行, 請改回

CODE:
[Copy to clipboard]
$message = nl2br(str_replace(array("\t", '   ', '  '), array('&nbsp; &nbsp; &nbsp; &nbsp; ', '&nbsp; &nbsp;', '&nbsp;&nbsp;'), $message));
return make_clickable($message);
==>

CODE:
[Copy to clipboard]
return $htmlon || $allowhtml ? make_clickable($message) : nl2br(str_replace(array("\t", '   ', '  '), array('&nbsp; &nbsp; &nbsp; &nbsp; ', '&nbsp; &nbsp;', '&nbsp;&nbsp;'), make_clickable($message)));


附件: discuzcode[1].func.php.txt (2006-5-23 08:15 PM, 16.25 K) / 該附件被下載次數 1
http://twed2k.org/attachment.php?aid=28959
發表人: 天驢風雲    時間: 2006-5-23 08:37 PM

熊小可以了:icons8
想請問剛剛我哪裡打錯
發表人: Vic    時間: 2006-5-23 08:57 PM

好像是在makeclickable內, 少了最上的

CODE:
[Copy to clipboard]
        // pad it with a space so we can match things at the start of the 1st line.
        $ret = ' ' . $text;
不過也是估計~ anyway....work就好了~
發表人: Jonson    時間: 2006-5-24 04:13 AM


引用:
Vic寫到:
好像是在makeclickable內, 少了最上的

CODE:
[Copy to clipboard]
        // pad it with a space so we can match things at the start of the 1st line.
        $ret = ' ' . $text;
不過也是估計~ anyway....work就好了~


問題是出在那邊沒錯。

CODE:
[Copy to clipboard]
        $ret = ' ' . $text;
這行指令是把呼叫自訂函數的參數前加個空白字元再指定給 ret 變數,
少了這個動作話,一開始 ret 變數就是空字串,而不是傳進函數的參數




歡迎光臨 TWed2k (http://twed2k.org/) Powered by Discuz! 4.1.0