网络营销电子商务研究中心

网络营销电子商务研究中心 (https://www.0058.net/index.php)
-   DedeCMS (https://www.0058.net/forumdisplay.php?f=71)
-   -   下载地址全局调用函数(独立调用软件模型的下载地址) (https://www.0058.net/showthread.php?t=4724)

Table Rock 2014-05-01 10:48 PM

下载地址全局调用函数(独立调用软件模型的下载地址)
 
1.优化全局变量及修复查询BUG;
2.增加后台可控制附件下载方式;
3.增加内容模型的判别,以防有复制软件模型的朋友;
Code:



    <?php   
    /* -------------------------------  
    Content:软件内容页下载地址调用  
    Author: 华强(QQ:3421209)  
    WebSite: 织梦教程网(http://www.xuewl.com)  
    UpDateTime: 2010-07-17  
    ==========  
    Tigs:   
    调用方法:{dede:field.id function="getsoftlinks(3,1,@me)"}   
    参数说明:  
        1.$channelid 是内容模型的ID;  
        2.调用类型(1 = 本地 ;2 = 镜像列表)  
        3.@me 为当前值,也是软件的文档ID编号  
    --------------------------------*/  
    function getsoftlinks($channelid,$type,$aid){   
        global $dsql;   
        $goto = $dsql->GetOne("Select * From `dede_softconfig` ");   
        $channeltable = $dsql->GetOne("select * from `dede_channeltype` where id = $channelid");   
        $addtable = $channeltable['addtable'];   
        $row = $dsql->GetOne("select * from `".$addtable."` where aid = $aid");    
        if ($type == 1){ //设置条件为调用本地下载   
            if($row['softlinks'] != ''){ //判断下载地址是否为空;   
                $dtp = new DedeTagParse();   
                $dtp->LoadSource($row['softlinks']);   
                foreach($dtp->CTags as $ctag){   
                    if($ctag->GetName()=='link'){ //读取 {dede:link}的标签   
                        $link = trim($ctag->GetInnerText()); //链接地址为底层模板;   
                        $serverName = trim($ctag->GetAtt('text')); //服务器名称   
                        $islocal = trim($ctag->GetAtt('islocal')); // 是否为本地的判断   
                        if ($islocal == 1){//本地下载链接   
                            if($goto['gotojump'] == 1){  //如果后台设置为链接到跳转页面,则对下载地址进行再次处理   
                                $uhash = substr(md5($link), 0, 24);   
                                $links = "/plus/download.php?open=2&id=$aid&uhash=$uhash";   
                            }      
                                return $links;   
                        }   
                    }   
                }   
            }              
        }   
        else if($type == 0){   
            if($row['softlinks'] != ''){ //判断下载地址是否为空;   
                $dtp = new DedeTagParse();   
                $dtp->LoadSource($row['softlinks']);   
                if(is_array($dtp->CTags)){   
                    foreach($dtp->CTags as $ctag){   
                        if($ctag->GetName()=='link'){ //读取 {dede:link}的标签   
                            $link = trim($ctag->GetInnerText()); //链接地址为底层模板;   
                            $serverName = trim($ctag->GetAtt('text')); //服务器名称   
                            $islocal = trim($ctag->GetAtt('islocal')); // 是否为本地的判断   
                            $rapidity = rand(0,70);   
                            if ($rapidity == 0){   
                                $line = 'stop';   
                            }   
                            elseif($rapidity <= 20){   
                                $line = 'busy';   
                            }   
                            elseif($rapidity <= 40){   
                                $line = 'nofree';   
                            }   
                            else{   
                                $line = 'free';   
                            }   
                            if ($islocal != 1){   
                                if($goto['gotojump'] == 1){//如果后台设置为链接到跳转页面,则对下载地址进行再次处理   
                                    $uhash = substr(md5($link), 0, 24);   
                                    $link = "/plus/download.php?open=2&id=$aid&uhash=$uhash";   
                                }   
                                $links =  "<tr><td class='line-name'><a href='".$link."' target='_blank'>".$serverName."</a></td><td>链接速度:</td><td class='line-speed'><p class='".$line." speed-bad'>".$rapidity."</p></td></tr>";   
                                $downlinks .= $links;   
                            }   
                        }   
                    }   
                }   
                $dtp->Clear();   
                return $downlinks;   
            }   
        }   
        else{   
            return "调用参数错误";   
        }   
    }   
    ?>  



All times are GMT +8. The time now is 04:06 AM.

Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.