file 本地文件傳輸協議,主要用於訪問本地計算機中的文件,就如同在 Windows 資源管理器中
打開文件一樣。 Discuz!X1.0 時內置過此傳輸協議,但是考慮到 Discuz!X2.0 及 Discuz!X1.5 主要被應用在能被外網訪問的服務器
上,所以去掉了此功能。現在有些站長提出自己使用 Discuz!X 系列產品是引用在公司內網,供內部交流使用,在發一些資料文檔時,加一些 file 本地文
件鏈接,但 file 本地文件傳輸協議在 Discuz!X1.5 及 Discuz!X2.0 中失效,現在寫些修改方法,提供給需要在內網使用 Discuz!X
系列版本產品的用户。下面以 Discuz!X2.0 為例,介紹修改方法:

 

找到 source/class/class_bbcode.php 文件,大約 36 行,

  1. "/[url]s*(https?://|ftp://|gopher://|news://|telnet://|rtsp://|mms://|callto://|ed2k://){1}([^["']+?)s*[/url]/i",

在|ftp://|後面加上 file://|;
大約第 60 行,

  1. returnpreg_replace("/(?<=[^]a-z0-9-="'/])((https?|ftp|gopher|news|telnet|mms|rtsp)://)([a-z0-9/-_+=.~!%@?#%&;:$()|]+)/i",
    "[url]13[/url]", ' '.$message);

在|ftp|後面加上 file|;
大約 97 行,

  1. if(!in_array(strtolower(substr($url, 0, 6)), array('http:/', 'https:', 'ftp://', 'rtsp:/', 'mms://'))) {

在'http:/', 後面加上'file://',;
找到 source/function/function_core.php 文件,大約 2689 行,

  1. if(preg_match_all("/((https?|ftp|gopher|news|telnet|rtsp|mms|callto)://|www.)([a-z0-9/-_+=.~!%@?#%&;:$()|]+s*)/i",
    $message, $urllist)) {

在|ftp|後面加上 file|;
找到 sourcefunctionfunction_discuzcode.php 文件,大約 100 行處,

 

  1. "/[url(=((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|thunder|qqdl|synacast){1}://|www.|mailto:)?([^s["']+?))?](.+?)[/url]/ies",
    "parseurl('1', '5', '2')", $message);

在|ftp|後面加上 file|;
大約 237 行,

  1. if(!$url
    &&
    preg_match("/((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|thunder|qqdl|synacast){1}://|www.)[^["']+/i",
    trim($text), $matches))

在|ftp|後面加上 file|;
大約 405 行,

  1. if(!in_array(strtolower(substr($url,
    0, 6)), array('http:/', 'https:', 'ftp://', 'rtsp:/', 'mms://'))
    && !preg_match('/^static//', $url))

在'http:/', 後面加上'file://', 。

這些位置修的改完,只適用於論壇發主題時使用,這樣修改完後,內網用户發本地文件超鏈接,就會直接打開了。