织梦dedecms软件频道判断是本站下载链接后再列出镜像的方法
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>今天把下载频道开启了镜像站点,开启了“ 根据本地地址和服务器列表自动生成 ”,这样较省事,不用每个都填。但是会遇到一个问题,当链接非本地时,也会去根据下载地址链接替换掉域名部分生成镜像下载点,这样就会出错,因为镜像站点其目录下根本没这个文件。所以想办法去加个判断,只有是自己域名的了解才生成镜像下载点。 <br>
详细的修改方法: <br>
找到文件include/taglib/channel/softlinks.lib.php,按如下来添加一个判断代码,只添加加粗部分即可,域名www.jb51.net请替换为自己网站域名即可。 <br>
</p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
<div class="right">
<span><u>复制代码</u></span>
</div>
<p>
代码如下:</p>
</div>
<div class="msgborder" id="phpcode1" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
<br>
if (strstr($firstLink, 'www.jb51.net')) //xiaoxin-20120818-判断是www.jb51.net域名下才出现镜像 <br>
{ //xiaoxin-20120818-判断是www.jb51.net域名下才出现镜像 <br>
$firstLink = preg_replace("#http:\/\/([^\/]*)\/#i", '/', $firstLink); <br>
foreach($sites as $site) <br>
{ <br>
if(trim($site)=='') continue; <br>
list($link,$serverName,$serverType) = explode('|', $site); <br>
if (!empty($link_type) && $link_type != trim($serverType)) continue; <br>
$link = trim( preg_replace("#\/$#", "", $link) ).$firstLink; <br>
$downloads = getDownloads($link); <br>
$uhash = substr(md5($link), 0, 24); <br>
if($row['gotojump']==1) <br>
{ <br>
$link = $phppath."/download.php?open=2&id={$refObj->ArcID}&uhash={$uhash}"; <br>
} <br>
$temp = str_replace("~link~", $link, $tempStr); <br>
$temp = str_replace("~server~", $serverName, $temp); <br>
$temp = str_replace("~downloads~", $downloads, $temp); <br>
$downlinks .= $temp; <br>
} </div>
頁:
[1]