<!--#include file="conn.asp"-->
<!--#include file="check.asp"-->
<% 
on error resume next
set fo=server.CreateObject("Scripting.FileSystemObject")
id=Request("id")
titleID=clng(request.QueryString("titleID"))
if id="" or isnull(id) then
 Response.Redirect("manage.asp")
end if
i=0
set rs=conn.execute("select * from [imgbook] where ID in("&id&")")
do while not rs.eof
	FilePath=rs("photo")&","&FilePath
	rs.movenext
	i=i+1
loop
rs.close:Set RS=nothing
conn.execute("delete from imgbook where ID in("&id&")")
conn.execute("update title set titleCount=titleCount-"&i&" where titleID="&titleID)

FilePath=split(FilePath,",")
for each FileName in FilePath
	if FileName<>"" then
	    s_filename=Replace(FileName,"UploadImages","UploadImages/s")
		fo.DeleteFile server.MapPath(FileName)
		fo.DeleteFile server.MapPath(s_filename)
	end if
next
set fo=nothing
response.Redirect("manage.asp")
%>