Rss & SiteMap
通信圈 http://www.k-94.cn/bbs
修改savepost.asp文件
找到mysessiondata(37)=Content
改為
mysessiondata(37) = ReplaceRemoteUrl(Content)
如果希望是管理員才能有這權(quán)限,則修改為
if dvbbs.master then
mysessiondata(37) = ReplaceRemoteUrl(Content)
else
mysessiondata(37) = Content
end if
在文件的最后一行End Function后面增加
\'================================================== \'過程名:ReplaceRemoteUrl \'作 用:替換字符串中的遠程文件為本地文件并保存遠程文件 \'參 數(shù):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 \'作 用:保存遠程的文件到本地 \'參 數(shù):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
\'************************************************** \'函數(shù)名:IsObjInstalled \'作 用:檢查組件是否已經(jīng)安裝 \'參 數(shù):strClassString ----組件名 \'返回值:True ----已經(jīng)安裝 \' False ----沒有安裝 \'************************************************** Function IsObjInstalled(strClassString) On Error Resume Next IsObjInstalled = False Err = 0 Dim xTestObj Set xTestObj = Server.CreateObject(strClassString) If 0 = Err Then IsObjInstalled = True Set xTestObj = Nothing Err = 0 End Function
\'按月份自動明名上傳文件夾,需要FSO組件支持。 Function CreatePath() Dim objFSO,Fsofolder,uploadpath uploadpath=year(now)&"-"&month(now) \'以年月創(chuàng)建上傳文件夾,格式:2003-8 On Error Resume Next Set objFSO = Server.CreateObject("Scripting.FileSystemObject") If objFSO.FolderExists(Server.MapPath(CheckFolder&uploadpath))=False Then objFSO.CreateFolder Server.MapPath(CheckFolder&uploadpath) End If If Err.Number = 0 Then CreatePath=uploadpath&"/" Else CreatePath="" End If Set objFSO = Nothing End Function
\'讀取上傳目錄 Function CheckFolder() If Dvbbs.Forum_Setting(76)="" Or Dvbbs.Forum_Setting(76)="0" Then Dvbbs.Forum_Setting(76)="UploadFile/" CheckFolder = Replace(Replace(Dvbbs.Forum_Setting(76),Chr(0),""),".","") \'在目錄后加(/) If Right(CheckFolder,1)<>"/" Then CheckFolder=CheckFolder&"/" End Function
這一功能是參考動力文章系統(tǒng)修改而來,能將復(fù)制過來的網(wǎng)頁上的圖片,在發(fā)表的同時保存在自己的空間,在我自己論壇上測試成功。但是不敢確定這一修改方法是否會帶來什么不良影響,請大家指正。
對于空間小的用戶來講,請不要使用或者只修改為管理員可以使用,否則,所有圖片存入本地空間,空間容量將會承受不住。