|
修改savepost.asp文件 找到mysessiondata(37)=Content 改为 mysessiondata(37) = ReplaceRemoteUrl(Content) 如果希望是管理员才能有这权限,则修改为 if dvbbs.master then mysessiondata(37) = ReplaceRemoteUrl(Content) else mysessiondata(37) = Content end if 在文件的最后一行End Function后面增加 '================================================== '过程名:ReplaceRemoteUrl '作 用:替换字符串中的远程文件为本地文件并保存远程文件 '参 数:strContent ------ 要替换的字符串 '================================================== function ReplaceRemoteUrl(strContent) if IsObjInstalled("Microsoft.XMLHTTP")=False then ReplaceRemoteUrl=strContent exit function end if dim re,RemoteFile,RemoteFileurl,SaveFileName,SaveFileType,arrSaveFileName,ranNum,UploadFiles,FormPath FormPath=CheckFolder&CreatePath() '上传目录路径 Set re=new RegExp re.IgnoreCase =true re.Global=True re.Pattern = "((http|https|ftp|rtsp|mms):(\/\/|\\\\){1}((\w)+[.]){1,}(net|com|cn|org|cc|tv|[0-9]{1,3})(\S*\/)((\S)+[.]{1}(gif|jpg|png|bmp)))" Set RemoteFile = re.Execute(strContent) For Each RemoteFileurl in RemoteFile arrSaveFileName = split(RemoteFileurl,".") SaveFileType=arrSaveFileName(ubound(arrSaveFileName)) ranNum=int(900*rnd)+100 SaveFileName = FormPath&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&"."&SaveFileType call SaveRemoteFile(SaveFileName,RemoteFileurl) strContent=Replace(strContent,RemoteFileurl,SaveFileName) if UploadFiles="" then UploadFiles=SaveFileName else UploadFiles=UploadFiles & "|" & SaveFileName end if Next ReplaceRemoteUrl=strContent end function '================================================== '过程名:SaveRemoteFile '作 用:保存远程的文件到本地 '参 数:LocalFileName ------ 本地文件名 ' RemoteFileUrl ------ 远程文件URL '================================================== sub SaveRemoteFile(LocalFileName,RemoteFileUrl) dim Ads,Retrieval,GetRemoteData Set Retrieval = Server.CreateObject("Microsoft.XMLHTTP") With Retrieval .Open "Get", RemoteFileUrl, False, "", "" .Send GetRemoteData = .ResponseBody End With Set Retrieval = Nothing Set Ads = Server.CreateObject("Adodb.Stream") With Ads .Type = 1 .Open .Write GetRemoteData .SaveToFile server.MapPath(LocalFileName),2 .Cancel() .Close() End With Set Ads=nothing end sub '************************************************** '函数名:IsObjInstalled '作 用:检查组件是否已经安装 '参 数:strClassString ----组件名 '返回值:True ----已经安装 ' False ----没有安装 '************************************************** Function IsObjInstalled(strClassString) On Error Resume Next
|