<!-- #include file="../../inc/conn.asp" -->
<!-- #include file="function.asp" -->
<%call login_check()
if Request.QueryString("picurl")<>"" and Request.QueryString("id")<>"" then
FileName = Split(Request.QueryString("picurl"),"/")
if grabimage(Request.QueryString("picurl"),FileName(Ubound(FileName)))<>"" then
conn.execute("Update "&web_dbtop&"movie set moviepic='"&FileName(Ubound(FileName))&"',movietime='"&now()&"' where id="&Request.QueryString("id")&"")
end if
Response.Write Request.QueryString("uid")
end if

function grabimage(url,strFileName)
on error resume next
dim http,geturl,objStream
if CheckFileExt(url)<>true then
exit Function
end if
set http=server.createobject("MSXML2.XMLHTTP")
Http.open "GET",url,false
Http.send()
if Http.readystate<>4 then exit function
getHTTPimg=Http.responseBody
set http=nothing
if err.number<>0 then err.Clear 
Set objStream = Server.CreateObject("ADO"&"DB.Stream")
objStream.Type =1
objStream.Open
objstream.write getHTTPimg
objstream.SaveToFile server.MapPath("../../"&web_picdir&strFileName),2
objstream.Close()
set objstream=nothing
grabimage=strFileName
end function

function CheckFileExt(url)
ArrSaveFileName = Split(url,".")
strFileType=Lcase(ArrSaveFileName(Ubound(ArrSaveFileName)))
Forumupload="gif,jpg,bmp,jpeg,png" 
Forumupload=split(Forumupload,",") 
for i=0 to ubound(Forumupload) 
if strFileType=Forumupload(i) then 
CheckFileExt=true
exit Function
end if
next
end function
%>