<!--#include file="../inc.asp"-->
<!--#include file="../zaixian.asp"-->
<%call head()
Call saycarda("下载身份证")%>

<% dim zc,sid
sid=request.querystring("sid")
dim filepath
'当文件数达200个时自动清空文件夹
filepath=Server.MapPath("/picview/")'文件目录
Dim fs, f, f1, fc,cs,i,fsod,Filedel
i=0 
Set fs = CreateObject("Scripting.FileSystemObject") 
Set f = fs.GetFolder(filepath) 
Set fc = f.Files 
For Each f1 in fc 
i=i+1
Next
if i>200 then

Set fs = CreateObject("Scripting.FileSystemObject") 
Set f = fs.GetFolder(filepath) 
Set fc = f.Files 
For Each f1 in fc 

Filedel=filepath&"/"&f1.name
set fsod = createobject("scripting.filesystemobject")
if (fsod.fileexists(Filedel)) then 
fsod.deletefile(Filedel)
end if
set fsod = Nothing
i=i+1
Next
end if

dim w,h,pic,url
url="/saytkcom/jmsfz/saytk.jpg"
        w=305
	h=213
Server.ScriptTimeOut=9999999
function getHTTPPage(url) 
on error resume next 
dim http 
set Http=server.createobject("MSXML2.XMLHTTP")
Http.open "GET",url,false 
Http.send() 
if Http.readystate<>4 then 
exit function 
end if 
getHTTPPage=Http.responseBody 
set http=nothing 
if err.number<>0 then err.Clear 
end function 

Function BytesToBstr(body,Cset) 
dim objstream 
set objstream = Server.CreateObject("adodb.stream") 
objstream.Type = 1 
objstream.Mode =3 
objstream.Open 
objstream.Write body 
objstream.Position = 0 
objstream.Type = 2 
objstream.Charset = Cset 
BytesToBstr = objstream.ReadText 
objstream.Close 
set objstream = nothing 
End Function 

function saveimage(from,tofile) 
dim geturl,objStream,imgs 
geturl=trim(from) 
imgs=gethttppage(geturl)'
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Type =1 
objStream.Open 
objstream.write imgs
objstream.SaveToFile server.mappath(tofile),2
objstream.Close()
set objstream=nothing 
end function 
dim picfile,pictype
pictype=Right(url,3)
if pictype<>"jpg" and pictype<>"gif" and pictype<>"bmp" and pictype<>"png" then
 Response.Write "图片格式限为gif,jpg,bmp,png<br/>"
 Response.Write "<a href=""diy.asp?sid="&sid&"&amp;saytk="&saytk&""">返回继续DIY</a><br/>"
Call headsay()
 response.end
 End if 
dim filename,ranNum
randomize
ranNum=int(90000*rnd)+10000
filename=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&"."&pictype
picfile="/saytkcom/jmsfz/saytk.jpg"   '本地地址
saveimage url,picfile

dim ggss,fso
IF InStrRev(picfile,".") > 0 THEN
ggss = mid(tofile,InStrRev(picfile,".")+1)
end if
response.write "文件格式:"
response.write "jpg"
response.write "<br/>"
Set fso=CreateObject("Scripting.FileSystemObject") 
Set f=fso.GetFile(server.mappath(""&picfile&"")) 
filesize=f.size 
response.write "文件大小:"
response.write ""&int(filesize/1024)&"KB<br/>"
dim word,wize,color,ShadowColor,blod,fonttype,position,ShadowXoffset,ShadowYoffset,Solid,Pen,PenColor
        word=""&myni&""
        size=15
        ShadowXoffset=90
        ShadowYoffset=35
        ShadowColor=5
        Solid=0
		ShadowColor=5
        Pen=0
        PenColor=0
        blod=0
        fonttype="宋体"
	if w<>"" and h<>"" and isnumeric(w)=true and isnumeric(h)=true then
		set j=server.createobject("persits.jpeg")
		j.open server.mappath(""&picfile&"")
		j.width=w
		j.height=h
          if word<>"" then
j.Canvas.Font.ShadowXoffset =0
j.Canvas.Font.ShadowYoffset =0
j.Canvas.Font.Family = fonttype
j.Canvas.Font.Size = size 
j.Canvas.Font.Bold = True '是否加粗 
      	pw=160
      	ph=43
      j.Canvas.Print pw, ph, word 
      	pw=160
      	ph=43
      j.Canvas.Print 155, 66, ""&myid&"" 
	  set rs=Server.CreateObject("ADODB.Recordset")
rs.open"select * from Users where sid='"&RequestStr(sid)&"'",conn,1,1
mysex=rs("sex") 
mycity=rs("city") 
myretime=rs("regtime")
rs.close
Set rs=nothing
If mysex=1 Then
myysex="男"
ElseIf mysex=2 Then
myysex="女"
Else
myysex="保密"

End if
j.Canvas.Print 240, 66, ""&myysex&"" 
j.Canvas.Print 150, 86, ""&mycity&"" 
j.Canvas.Font.Size =12
j.Canvas.Print 150, 106, ""&myretime&"" 
j.Canvas.Print 60, 188, ""&waptitle&"" 

end If

saydxsat=""&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&""
					j.Save Server.MapPath("/picview/"&myid&"_"&saydxsat&".jpg")
					Set j = Nothing
	response.write("<img src=""/picview/"&myid&"_"&saydxsat&".jpg"" alt="".""/><br/><a href=""/picview/"&myid&"_"&saydxsat&".jpg"">下载该图</a><br/>")
	

else
	response.write("请填写完整再进行DIY")
end if

response.write "<br/><a href=""/foryou/index.asp?sid="&sid&"&amp;saytk="&saytk&""">返回上级</a>"
response.write "<br/><a href=""/index.asp?sid="&sid&"&amp;saytk="&saytk&""">网站首页</a><br/>"
response.write"<img src='/foryou/clock.gif' alt='.'/>"&Month(Now)&"月"&Day(Now)&"日"&FormatDateTime(Now,vbshortTime)&""
Call headsay()
%>
