<%
Function Dv_UbbCode_Upload(strText,PostUserGroup,Flag,MaxLoopCount,abgcolor)
	Dim re
	Dim Test
	Dim LoopCount
	Dim s

	Set re=new RegExp
	re.IgnoreCase =True
	re.Global=True
	s=strText

	LoopCount=0
	re.Pattern="(^.*)\[upload=(.[^\]\n]+)\]viewFile\.asp\?id=*([0-9]*)\x01\/UPLOAD\](.*)"
	Test=re.Test(s)
	If Test Then
		Dim UpSQL,UpRs
		Dim UploadID
		Dim TrueFileName
		Dim TruePos
		Dim FileLen
		Dim iDownUser
		Dim SplitDownUser
		Dim iii

		Do While Test
			UploadID=re.Replace(s,"$3")
			If IsNumeric(UploadID) Then
				UpSQL="Select F_Filename,F_FileType,F_FileSize,F_DownNum,F_DownUser From DV_Upfile Where F_ID="&Trim(UploadID)
				Set UpRs = Dvbbs.Execute(UpSQL)
				If Not UpRs.Eof And Not UpRs.Bof Then
					TruePos=InStrRev(UpRs("F_Filename"),"___")
					If TruePos>0 Then
						TrueFileName=Left(UpRs("F_Filename"),TruePos-1)
					Else
						TrueFileName=UpRs("F_Filename")
					End If
					TruePos=instrrev(TrueFileName,"/")
					If TruePos>0 Then
						TrueFileName=Right(TrueFileName,Len(TrueFileName)-TruePos)
					End If
					FileLen=UpRs("F_FileSize")
					If FileLen>1024 Then
						FileLen=Round(FileLen / 1024,2)
						If FileLen > 1024 Then
							FileLen=Round(FileLen / 1024,2)
							FileLen="<B>" & FileLen & "</B> MByte"
						Else
							FileLen="<B>" & FileLen & "</b> KByte"
						End If
					Else
						FileLen="<B>" & FileLen & "</B> Byte"
					End If
					'If Dvbbs.MemberName<>"" And (Dvbbs.MemberName=UserName Or Dvbbs.Master) Then
						If (Not IsNull(UpRs("F_DownUser"))) And UpRs("F_DownUser")<>"" Then
							SplitDownUser=Split(UpRs("F_DownUser"),"|")
							iDownUser="<select size=1><option value=0>以下用户</option>"
							For iii=0 To ubound(SplitDownUser)
								iDownUser=iDownUser & "<option value="&iii&">"&SplitDownUser(iii)&"</option>"
							Next
							iDownUser=iDownUser&"</select>"
						Else
							iDownUser=""
						End If
						s=re.Replace(s,"$1 <table border=0 cellspacing=2 class=tableborder4 style=width:550px;><tr><td colspan=2 height=20 class=tablebody3>&nbsp;<B>下载信息</B></td></tr><tr><td colspan=2 height=20 class=tablebody1><IMG  title=空谷寻梦社区 src=""skins/default/filetype/"&UpRs("F_FileType")&".gif"" border=0><A href=""viewFile.asp?BoardID="&Dvbbs.Boardid&"&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> <BR>$4")
					'Else
						'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="&Dvbbs.Boardid&"&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")
					'End If
				Else
					s=re.Replace(s,"$1<BR>本帖包含附件，但是附件文件已被删除或文件已经损坏！<BR>$4")
				End If
				UpRs.Close
			End if
			re.Pattern="(^.*)\<\/FONT\>\&nbsp\;次\&nbsp\;\)\<\/TD\>\<\/TR\>\<\/TABLE\>\<\/FIELDSET\>(\<BR\>){0,}\<FIELDSET\>\<LEGEND\>本帖包含附件\<\/LEGEND\>\<TABLE cellSpacing=3 border=0 cellpadding=0\>(.*)"
			s=re.Replace(s,"$1</FONT>&nbsp;次&nbsp;)</TD></TR>$3")
			re.Pattern="(^.*)\[upload=(.[^\]\n]+)\]viewFile\.asp\?id=*([0-9]*)\x01\/UPLOAD\](.*)"
			Test=re.Test(s)
			LoopCount=LoopCount+1
			If LoopCount>MaxLoopCount Then Exit Do
		Loop
	End If
	Dv_UbbCode_Upload=s
	Set Re=Nothing
End Function
%>
