VB code
<% '***********************************************'函數名:getPicUrl'作 用:獲得資訊裡的圖片地址'參 數:str ----資訊'***********************************************function getPicUrl(str) dim content,regstr,url content=str&"" 'regstr="src=.+?.(gif|jpg|bmp|doc)" regstr="UploadFiles/.+?.(gif|jpg|bmp|doc)" 'url=Replace(Replace(Replace(RegExp_Execute(regstr,content),"'",""),"""",""),"src=","") url=Replace(Replace(Replace(RegExp_Execute(regstr,content),"'",""),"""",""),"/UploadFiles/","") getPicUrl=urlend functionFunction RegExp_Execute(patrn, strng)Dim regEx, Match, Matches,values '建立變數。Set regEx = New RegExp '建立Regex。regEx.Pattern = patrn '設定模式。regEx.IgnoreCase = true '設定是否區分字元大小寫。regEx.Global = True '設定全域可用性。Set Matches = regEx.Execute(strng) '執行搜尋。For Each Match in Matches '遍曆匹配集合。values=values&Match.Value&","NextRegExp_Execute = valuesEnd Function'***********************************************'函數名:DeleteFile'作 用:刪除檔案'參 數:file ----檔案路徑'***********************************************Function DeleteFile(file)dim fsoSet fso = CreateObject("scripting.filesystemobject")'if fso.fileExists(file) then fso.DeleteFile server.MapPath(file) 'Else ' response.Write(" 檔案不存在!")'end ifSet fso = nothingEnd Function%><% iii=0typeid=request("typeid")pageon=request("pageon")type_name=request("typename")selectcount=request("selectcount")for ii=1 to selectcountid=request("cid"&ii)if id<>"" then'***********************************************'函數名:Delete'作 用:刪除檔案'參 數:file ----檔案路徑'***********************************************set rsD=server.CreateObject("adodb.recordset")sqlD = "select * from content_table where id = "&id&"" rsD.open sqlD,con,1,3 if rsD.bof and rsD.eof then Alert 1,"錯誤的參數!","" response.End() else dim picUrl,picUrl1 dim picUrlArray dim x,y picUrl = getPicUrl(rsD("content")) '刪除形象照片代碼開始 if rsD("prdPic")<>"" then picUrl1 = replace(rsD("prdPic"),"../","/") DeleteFile(picUrl1) 'response.Write("不為空白") end if '刪除形象照片代碼結束 if picUrl <> "" then picUrl = left(picUrl,len(picUrl)-1) picUrlArray = split(picUrl,",") for x = 0 to ubound(picUrlArray) if instr(picUrlArray(x),"/UploadFiles/") > 0 then DeleteFile(picUrlArray(x)) end if next end if rsD.delete end if rsD.closestrSQL="delete from content_Table where id ="&id CmdBegin adcmdtext,strSQL CmdExec()iii=1%><%end ifnextif iii=1 then%><script>alert("已永久刪除!")location.href="info.asp?typeid=<%=typeid%>&pageon=<%=pageon%>&typename=<%=type_name%>"</script><%else%><script>alert("刪除失敗!")history.back()</script><%end if%>