<!--#include file="inc/conn.asp"-->
<!--#include file="inc/safe.asp"-->
<!--#include file="inc/config.asp"-->
<!--#include file="inc/const.asp"-->
<!--#include file="inc/UpLoadClass.asp"-->
<!--#include file="inc/chkimage.asp"-->
<%
if MemberName="" then
  response.Redirect("userlogin.asp")
  response.end
end if
%>
<%
dim errmsg,action
errmsg=""

action=request.QueryString("type")

'on error resume next

select case action
  case "fm"
    fmphoto
  case "gr"
    grphoto
end select

Sub fmphoto()
  dim request2
  set request2=New UpLoadClass
  request2.SavePath="uppic/photo/"
  request2.maxsize=307200
  request2.FileType = "gif/jpg"
  request2.open()
  
  image=request2.form("pic1")  
 if image<>"" then
  select case Request2.form("pic1_Err")			
	case 1:
		errmsg=errmsg+"<br><li>文件太大，拒绝上传"		
	case 2:
		errmsg=errmsg+"<br><li>文件格式不对，拒绝上传"		
	case 3:
		errmsg=errmsg+"<br><li>文件太大且格式不对，拒绝上传"
  end select
 end if
 
 imagepath="uppic/photo/"& image
 Checkimg(imagepath)
 
 if errmsg<>"" then 
  response.Write "错误信息：<br>"
  response.write("　　　"+ errmsg)
  response.Write "<input type='button' value='返回修改' onClick='javascript:window.history.back();'>"
  response.Write "<input type='button' value='关闭窗口' onClick='javascript:window.close();'>"
  response.end
 end if
 set rs=server.CreateObject("adodb.recordset") 
 sql="select photo from user_info where userid="& userid &""
 rs.open sql,conn,1,3
 rs("photo")=image 
 rs.update
 rs.close
 set rs=nothing
 conn.close
 set conn=nothing
  BackInfo("photo.asp")
End Sub

Sub grphoto()
  dim pnum
  select case memberclass
   case "注册会员"
     pnum=10
   case "普通会员"
     pnum=15
   case "VIP会员"
     pnum=20
  end select
  
  if clng(GetPhotoNum(Userid))>clng(pnum) then
     response.Write "<script language='javascript'>alert('您的个人相册空间已满，无法上传照片。');window.location='myphoto.asp'</script>"
	 response.end
  end if
  
  dim request2
  set request2=New UpLoadClass
  request2.SavePath="uppic/photo/"
  request2.maxsize=307200
  request2.FileType = "gif/jpg"
  request2.open()
  
  image=request2.form("pic2") 
  title=trim(ReplaceBadChar(request2.form("title")))
 if image<>"" then
  select case Request2.form("pic2_Err")			
	case 1:
		errmsg=errmsg+"<br><li>文件太大，拒绝上传"		
	case 2:
		errmsg=errmsg+"<br><li>文件格式不对，拒绝上传"		
	case 3:
		errmsg=errmsg+"<br><li>文件太大且格式不对，拒绝上传"
  end select
 end if
 
 imagepath="uppic/photo/"& image
 Checkimg(imagepath)
 
 if title="" then errmsg=errmsg+"<br>"+"<li>文章的标题不能为空！"
 if invalidch(title) or instr(title,"，")>0  then errmsg=errmsg+"<br>"+"<li>您的标题可能含特殊符号，请检查！"
 if errmsg<>"" then 
  response.Write "错误信息：<br>"
  response.write("　　　"+ errmsg)
  response.Write "<input type='button' value='返回修改' onClick='javascript:window.history.back();'>"
  response.Write "<input type='button' value='关闭窗口' onClick='javascript:window.close();'>"
  response.end
 end if
 
 conn.execute("insert into photo_info(userid,photo,title,dtime) values("& userid &",'"& image &"','"& title &"','"& now() &"')") 
 conn.close
  set conn=nothing
 BackInfo("myphoto.asp")
End Sub
%>