ChannelFields)) { ShowMsg('獲取文檔信息失敗!','-1'); exit(); } $vname = ''; foreach($cu->ChannelFields as $k=>$v) { if($v['type']=='softlinks'){ $vname=$k; break; } } $row = $dsql->GetOne("SELECT $vname FROM `".$cu->ChannelInfos['addtable']."` WHERE aid='$aid'"); include_once(DEDEINC.'stat.html'); $ctag = ''; $downlinks = ch_softlinks($row[$vname], $ctag, $cu, '', TRUE); require_once(DEDETEMPLATE.'/plus/download_links_templet.htm'); exit(); } /*------------------------ //提供軟件給用(yòng)戶下(xià)載(舊(jiù)模式) function getSoft_old() ------------------------*/ else if($open==1) { //更新下(xià)載次數 $id = isset($id) && is_numeric($id) ? $id : 0; $link = base64_decode(urldecode($link)); $hash = md5($link); $rs = $dsql->ExecuteNoneQuery2("UPDATE `#@__downloads` SET downloads = downloads + 1 WHERE hash='$hash' "); if($rs <= 0) { $query = " INSERT INTO `#@__downloads`(`hash`,`id`,`downloads`) VALUES('$hash','$id',1); "; $dsql->ExecNoneQuery($query); } header("location:$link"); exit(); } /*------------------------ //提供軟件給用(yòng)戶下(xià)載(新模式) function getSoft_new() ------------------------*/ else if($open==2) { $id = intval($id); //獲得(de)附加表信息 $row = $dsql->GetOne("SELECT ch.addtable,arc.mid FROM `#@__arctiny` arc LEFT JOIN `#@__channeltype` ch ON ch.id=arc.channel WHERE arc.id='$id' "); if(empty($row['addtable'])) { ShowMsg('找不到所需要的(de)軟件資源!', 'javascript:;'); exit(); } $mid = $row['mid']; //讀取連接列表、下(xià)載權限信息 $row = $dsql->GetOne("SELECT softlinks,daccess,needmoney FROM `{$row['addtable']}` WHERE aid='$id' "); if(empty($row['softlinks'])) { ShowMsg('找不到所需要的(de)軟件資源!', 'javascript:;'); exit(); } $softconfig = $dsql->GetOne("SELECT * FROM `#@__softconfig` "); $needRank = $softconfig['dfrank']; $needMoney = $softconfig['dfywboy']; if($softconfig['argrange']==0) { $needRank = $row['daccess']; $needMoney = $row['needmoney']; } //分(fēn)析連接列表 require_once(DEDEINC.'stat.html'); $softUrl = ''; $islocal = 0; $dtp = new DedeTagParse(); $dtp->LoadSource($row['softlinks']); if( !is_array($dtp->CTags) ) { $dtp->Clear(); ShowMsg('找不到所需要的(de)軟件資源!', 'javascript:;'); exit(); } foreach($dtp->CTags as $ctag) { if($ctag->GetName()=='link') { $link = trim($ctag->GetInnerText()); $islocal = $ctag->GetAtt('islocal'); //分(fēn)析本地鏈接 if(!isset($firstLink) && $islocal==1) $firstLink = $link; if($islocal==1 && $softconfig['islocal'] != 1) continue; //支持http,迅雷下(xià)載,ftp,flashget if(!preg_match("#^http:\/\/|^thunder:\/\/|^ftp:\/\/|^flashget:\/\/#i", $link)) { $link = $cfg_mainsite.$link; } $dbhash = substr(md5($link), 0, 24); if($uhash==$dbhash) $softUrl = $link; } } $dtp->Clear(); if($softUrl=='' && $softconfig['ismoresite']==1 && $softconfig['moresitedo']==1 && trim($softconfig['sites'])!='' && isset($firstLink)) { $firstLink = preg_replace("#http:\/\/([^\/]*)\/#i", '/', $firstLink); $softconfig['sites'] = preg_replace("#[\r\n]{1,}#", "\n", $softconfig['sites']); $sites = explode("\n", trim($softconfig['sites'])); foreach($sites as $site) { if(trim($site)=='') continue; list($link, $serverName) = explode('|', $site); $link = trim( preg_replace("#\/$#", "", $link) ).$firstLink; $dbhash = substr(md5($link), 0, 24); if($uhash == $dbhash) $softUrl = $link; } } if( $softUrl == '' ) { ShowMsg('找不到所需要的(de)軟件資源!', 'javascript:;'); exit(); } //------------------------- // 讀取文檔信息,判斷權限 //------------------------- $arcRow = GetOneArchive($id); if($arcRow['aid']=='') { ShowMsg('無法獲取未知文檔的(de)信息!','-1'); exit(); } extract($arcRow, EXTR_SKIP); //處理(lǐ)需要下(xià)載權限的(de)軟件 if($needRank>0 || $needMoney>0) { require_once(DEDEINC.'stat.html'); $cfg_ml = new MemberLogin(); $arclink = $arcurl; $arctitle = $title; $arcLinktitle = "".$arctitle.""; $pubdate = GetDateTimeMk($pubdate); //會員(yuán)級别不足 if(($needRank>1 && $cfg_ml->M_Rank < $needRank && $mid != $cfg_ml->M_ID)) { $dsql->Execute('me' , "SELECT * FROM `#@__arcrank` "); while($row = $dsql->GetObject('me')) { $memberTypes[$row->rank] = $row->membername; } $memberTypes[0] = "遊客"; $msgtitle = "你沒有權限下(xià)載軟件:{$arctitle}!"; $moremsg = "這(zhè)個(gè)軟件需要 ".$memberTypes[$needRank]." 才能下(xià)載,你目前是:".$memberTypes[$cfg_ml->M_Rank]." !"; include_once(DEDETEMPLATE.'/plus/view_msg.htm'); exit(); } //以下(xià)爲正常情況,自動扣點數 //如果文章(zhāng)需要金币,檢查用(yòng)戶是否浏覽過本文檔 if($needMoney > 0 && $mid != $cfg_ml->M_ID) { $sql = "SELECT aid,money FROM `#@__member_operation` WHERE buyid='ARCHIVE".$id."' AND mid='".$cfg_ml->M_ID."'"; $row = $dsql->GetOne($sql); //未購(gòu)買過此文章(zhāng) if( !is_array($row) ) { //沒有足夠的(de)金币 if( $needMoney > $cfg_ml->M_Money || $cfg_ml->M_Money=='') { $msgtitle = "你沒有權限下(xià)載軟件:{$arctitle}!"; $moremsg = "這(zhè)個(gè)軟件需要 ".$needMoney." 金币 才能下(xià)載,你目前擁有金币:".$cfg_ml->M_Money." 個(gè) !"; include_once(DEDETEMPLATE.'/plus/view_msg.htm'); exit(0); } //有足夠金币,記錄用(yòng)戶信息 $inquery = "INSERT INTO `#@__member_operation`(mid,oldinfo,money,mtime,buyid,product,pname,sta) VALUES ('".$cfg_ml->M_ID."','$arctitle','$needMoney','".time()."', 'ARCHIVE".$id."', 'archive','下(xià)載軟件', 2); "; //記錄定單 if( !$dsql->ExecuteNoneQuery($inquery) ) { ShowMsg('記錄定單失敗, 請返回', '-1'); exit(0); } //扣除金币 $dsql->ExecuteNoneQuery("UPDATE `#@__member` SET money = money - $needMoney WHERE mid='".$cfg_ml->M_ID."'"); } } } //更新下(xià)載次數 $hash = md5($softUrl); $rs = $dsql->ExecuteNoneQuery2("UPDATE `#@__downloads` SET downloads = downloads+1 WHERE hash='$hash' "); if($rs <= 0) { $query = " INSERT INTO `#@__downloads`(`hash`, `id`, `downloads`) VALUES('$hash', '$id', 1); "; $dsql->ExecNoneQuery($query); } header("location:{$softUrl}"); exit(); }//opentype=2