<%if Session("weight")=0 then 
Response.Redirect "error.asp?cause=4"
 end if
%><object runat=server id=conn1 progid="adodb.connection"></object>
<%application.Lock
conn1.Open Application("p_jyzx")
Application.UnLock
%>
<%
dim rs
dim formsize,formdata,bncrlf,divider,datastart,dataend,mydata
ptitle=Request("ptitle")
formsize=request.totalbytes
formdata=request.binaryread(formsize)
bncrlf=chrB(13) & chrB(10)
divider=leftB(formdata,clng(instrb(formdata,bncrlf))-1)
datastart=instrb(formdata,bncrlf & bncrlf)+4
dataend=instrb(datastart+1,formdata,divider)-datastart
mydata=midb(formdata,datastart,dataend)
if formsize>200000 then
	response.redirect "my_photo.asp"
end if
%>

<%photo_num=2
if Session("weight")=2 then
	photo_num=4
end if 
Set rs1 = Server.CreateObject("ADODB.Recordset")
rs1.open "select * from user where user_name='" &session("Current_user")&"'",conn1,3
if rs1("photo")<photo_num then
	
%>
<%
Set rs = Server.CreateObject("ADODB.Recordset")
rs.open "select * from user where user_name='" &session("Current_user")&"'",conn1,3,2
rs("photo")=rs("photo")+1

sex=rs("sex")
rs.update

%><object runat=server id=connpic progid="adodb.connection"></object>
<%application.Lock
connpic.Open Application("p_pic")

Application.UnLock
%>
<%
if rs1("photo")=0 then
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "pic",connpic,3,2
rs.addnew
rs("big").appendchunk mydata
rs("user_name")=session("Current_user")
rs("ptitle")=ptitle
rs("sex")=sex
rs("selected")=1
rs("date")=date
rs.update
set rs=nothing
else
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "pic",connpic,3,2
rs.addnew
rs("big").appendchunk mydata
rs("user_name")=session("Current_user")
rs("ptitle")=ptitle
rs("sex")=sex
rs("selected")=0
rs("date")=date
rs.update
set rs=nothing
end if


response.redirect "my_photo.asp"
%>
<%else
response.redirect "my_photo.asp"
end if%>