<div class="t_msgfont" id="message12018"><p>实现如下功能: </p><p>1、单贴间多个下载文件单独记录下载次数并显示文件名(这个只是以前那个的Bug修复) </p><p>2、显示原来上传时的文件名,而不是变成序号的文件名(不影响保密功能) </p><p>3、可以查看下载者的功能(只有发布者和管理员可以看到,别人看不到) </p><p>4、文件长度显示,该Byte就Byte,该KByte就KByte,该MByte就MByte(应该不会有那个论坛提供GByte下载吧) </p><p>5、无论上传文件后系统加了什么样的后缀序号(其实是用于防盗和防止文件重名的),下载时都会只显示原来的文件名,不会出现后边的一长串序号(这个功能要在系统开启了防盗功能才有效) </p><p>一、修改inc/dv_ubbcode.asp: </p><p><font color="#ff0000">原来:</font>
</p><p>re.Pattern="\x01UPLOAD=(.[^\x01]*)\x02(viewFile\.asp.[^\x01]*)\x01\/UPLOAD\x02"<br/>s= re.Replace(s,"<br><IMG SRC=""skins/default/filetype/$1.gif"" border=0> <a href=""$2"" target=_blank>点击浏览该文件</a>")<br/>re.Pattern="viewFile.asp\?"<br/>s= re.Replace(s,"viewFile.asp?Boardid="&Dvbbs.Boardid&"&")<br/>re.Pattern="\x01UPLOAD=(.[^\x01]*)\x02(.[^\x01]*)\x01\/UPLOAD\x02"<br/>s= re.Replace(s,"<br><img src=""skins/default/filetype/$1.gif"" border=""0""> <a href=""$2"" target=""_blank"">点击浏览该文件</a><br><img src=""$2"" border=""0"" >")<br/><br/>这个是标准DV的代码,不含以前修改的代码(如果你已经修改过,请恢复为DV7标准代码) </p><p><font color="#0000ff">改为:</font>
</p><p>Dim Test<br/>Dim LoopCount<br/>LoopCount=0<br/>re.Pattern="(^.*)\x01UPLOAD=(.[^\x01]*)\x02viewFile\.asp\?id=*([0-9]*)\x01\/UPLOAD\x02(.*)"<br/>Test=re.Test(s)<br/>if Test then<br/>dim upsql,uprs<br/>dim uploadid<br/>dim TrueFileName<br/>dim TruePos<br/>dim FileLen<br/>dim iDownUser<br/>dim SplitDownUser<br/>dim iii<br/>Set uprs = Server.CreateObject("ADODB.Recordset")<br/>do while Test<br/>uploadid=re.Replace(s,"$3")<br/>if IsNumeric(uploadid) then<br/>upsql="select F_Filename,F_FileType,F_FileSize,F_DownNum,F_DownUser from DV_Upfile where F_ID="&trim(uploadid)<br/>uprs.Open upsql,conn,1,1<br/>TruePos=instrrev(uprs("F_Filename"),"___")<br/>if TruePos>0 then<br/>TrueFileName=left(uprs("F_Filename"),TruePos-1)<br/>else<br/>TrueFileName=uprs("F_Filename")<br/>end if<br/>TruePos=instrrev(TrueFileName,"/")<br/>if TruePos>0 then<br/>TrueFileName=right(TrueFileName,len(TrueFileName)-TruePos)<br/>end if<br/>FileLen=uprs("F_FileSize")<br/>if FileLen>1024 then<br/>FileLen=Round(FileLen / 1024,2)<br/>if FileLen > 1024 then<br/>FileLen=Round(FileLen / 1024,2)<br/>FileLen="<B>" & FileLen & "</B> MByte"<br/>else<br/>FileLen="<B>" & FileLen & "</b> KByte"<br/>end if<br/>else<br/>FileLen="<B>" & FileLen & "</B> Byte"<br/>end if<br/>if dvbbs.membername<>"" and (dvbbs.membername=username or dvbbs.master) then<br/>if (not isnull(uprs("F_DownUser"))) and uprs("F_DownUser")<>"" then<br/>SplitDownUser=split(uprs("F_DownUser"),"|")<br/>iDownUser="<select size=1><option value=0>以下用户</option>"<br/>for iii=0 to ubound(SplitDownUser)<br/>iDownUser=iDownUser & "<option value="&iii&">"&SplitDownUser(iii)&"</option>"<br/>next<br/>iDownUser=iDownUser&"</select>"<br/>else<br/>iDownUser=""<br/>end if<br/>s= re.Replace(s,"$1<BR><FIELDSET><LEGEND>本帖包含附件</LEGEND><TABLE cellSpacing=3 border=0 cellpadding=0><tr height=25 valign=middle><td><IMG src=""skins/default/filetype/"&uprs("F_FileType")&".gif"" border=0></td><TD><A href=""viewFile.asp?Boardid=8&ID="&trim(uploadid)&""" target=_blank>"&TrueFileName&"</A>&nbsp; (&nbsp;"&FileLen&",已被"&iDownUser&"下载 <FONT color=red><b>"&uprs("F_DownNum")&"</b></FONT>&nbsp;次&nbsp;)</TD></TR></TABLE></FIELDSET><BR>$4")<br/>else<br/>s= re.Replace(s,"$1<BR><FIELDSET><LEGEND>本帖包含附件</LEGEND><TABLE cellSpacing=3 border=0 cellpadding=0><tr height=25 valign=middle><td><IMG src=""skins/default/filetype/"&uprs("F_FileType")&".gif"" border=0></td><TD><A href=""viewFile.asp?Boardid=8&ID="&trim(uploadid)&""" target=_blank>"&TrueFileName&"</A>&nbsp; (&nbsp;"&FileLen&",已被下载 <FONT color=red><b>"&uprs("F_DownNum")&"</b></FONT>&nbsp;次&nbsp;)</TD></TR></TABLE></FIELDSET><BR>$4")<br/>end if<br/>uprs.close<br/>end if<br/>re.Pattern="(^.*)\<\/FONT\>\&nbsp\;次\&nbsp\;\)\<\/TD\>\<\/TR\>\<\/TABLE\>\<\/FIELDSET\>(\<BR\>){0,}\<FIELDSET\>\<LEGEND\>本帖包含附件\<\/LEGEND\>\<TABLE cellSpacing=3 border=0 cellpadding=0\>(.*)"<br/>s=re.Replace(s,"$1</FONT>&nbsp;次&nbsp;)</TD></TR>$3")<br/>re.Pattern="(^.*)\x01UPLOAD=(.[^\x01]*)\x02viewFile\.asp\?id=*([0-9]*)\x01\/UPLOAD\x02(.*)"<br/>Test=re.Test(s)<br/>LoopCount=LoopCount+1<br/>If LoopCount>MaxLoopCount Then Exit Do<br/>loop<br/>end if </p><p><br/>二、修改viewfile.asp: </p><p><font color="#ff0000">1、原来:</font>
</p><p>If Dvbbs.Forum_Setting(75)="0" Then<br/>Dvbbs.Execute("Update dv_upfile Set F_DownNum=F_DownNum+1 Where F_ID="&DownID)<br/>Response.Redirect uploadpath&rs("F_filename")<br/>Else<br/>filename=Replace(rs("F_filename"),"..","")&""<br/>If Request.ServerVariables("HTTP_REFERER")="" Or InStr(Request.ServerVariables("HTTP_REFERER"),Request.ServerVariables("SERVER_NAME"))=0 Or filename="" Then<br/>Response.Redirect "index.asp"<br/>Else<br/>Call downloadFile(Server.MapPath(Dvbbs.Forum_Setting(76)&filename))<br/>End If<br/>End If </p><p><font color="#0000ff">现在:</font>
</p><p>If Dvbbs.Forum_Setting(75)="0" Then<br/>if dvbbs.membername<>"" then<br/>if not instr(1,"|"&rs("f_downuser")&"|","|"&dvbbs.membername&"|")>0 then<br/>if isnull(rs("F_DownUser")) or rs("F_DownUser")="" then<br/>conn.execute("update dv_upfile set F_DownNum=F_DownNum+1,F_DownUser='"&dvbbs.membername&"' where F_ID="&DownID)<br/>else<br/>conn.execute("update dv_upfile set F_DownNum=F_DownNum+1,F_DownUser=F_DownUser+'|"&dvbbs.membername&"' where F_ID="&DownID)<br/>end if<br/>end if<br/>else<br/>Dvbbs.Execute("Update dv_upfile Set F_DownNum=F_DownNum+1 Where F_ID="&DownID)<br/>end if<br/>Response.Redirect uploadpath&rs("F_filename")<br/>Else<br/>filename=Replace(rs("F_filename"),"..","")&""<br/>If Request.ServerVariables("HTTP_REFERER")="" Or InStr(Request.ServerVariables("HTTP_REFERER"),Request.ServerVariables("SERVER_NAME"))=0 Or filename="" Then<br/>Response.Redirect "index.asp"<br/>Else<br/>if dvbbs.membername<>"" then<br/>if not instr(1,"|"&rs("f_downuser")&"|","|"&dvbbs.membername&"|")>0 then<br/>if isnull(rs("F_DownUser")) or rs("F_DownUser")="" then<br/>conn.execute("update dv_upfile set F_DownNum=F_DownNum+1,F_DownUser='"&dvbbs.membername&"' where F_ID="&DownID)<br/>else<br/>conn.execute("update dv_upfile set F_DownNum=F_DownNum+1,F_DownUser=F_DownUser+'|"&dvbbs.membername&"' where F_ID="&DownID)<br/>end if<br/>end if<br/>else<br/>Dvbbs.Execute("Update dv_upfile Set F_DownNum=F_DownNum+1 Where F_ID="&DownID)<br/>end if<br/>Call downloadFile(Server.MapPath(Dvbbs.Forum_Setting(76)&filename))<br/>End If<br/>End If </p><p><br/><font color="#ff0000">2、原来:</font>
</p><p>If Response.IsClientConnected Then <br/>Response.AddHeader "Content-Disposition", "attachment; filename=" & f.name </p><p><font color="#0000ff">现在:</font>
</p><p>If Response.IsClientConnected Then <br/>dim TruePos<br/>dim TrueFileName<br/>TruePos=instrrev(f.name,"___")<br/>if TruePos>0 then<br/>TrueFileName=left(f.name,TruePos-1)<br/>else<br/>TrueFileName=f.name<br/>end if<br/>TruePos=instrrev(TrueFileName,"/")<br/>if TruePos>0 then<br/>TrueFileName=right(TrueFileName,len(TrueFileName)-TruePos)<br/>end if<br/>Response.AddHeader "Content-Disposition", "attachment; filename=" & TrueFileName <br/>全部完成!</p></div> |