<!--#include file="conn.asp"-->
<!--#include file="user_chkpass.asp"-->
<!--#include file="inc/function.asp"-->
<!--#include file="inc/md5.asp"-->
<html>
<head>
<title>修改我的blog资料</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="Admin_STYLE.CSS" rel="stylesheet" type="text/css">
<body leftmargin="2" topmargin="0" marginwidth="0" marginheight="0" class="bgcolor">
<br>
<%
if CheckUserLogined()=False then
	response.Redirect "user_login.asp"
end if
dim rsuser,action,sqlUser,founderr,errmsg
action=trim(request("action"))
if action="SaveModify" then 
	call savemodify()
end if

sub savemodify()
	dim UserID,Password,PwdConfirm,Question,Answer,Sex,Email,Homepage,OICQ,MSN
	dim blogname,user_showlog_num,user_showcomment_num,user_showmessage_num,user_shownewlog_num
	dim user_shownewcomment_num,user_shownewmessage_num,user_showlogword_num,en_blogteam
	UserID=trim(request("UserID"))
	if UserID="" then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>参数不足！</li>"
		exit sub
	else
		userID=Clng(userID)
	end if
	Password=trim(request("Password"))
	PwdConfirm=trim(request("PwdConfirm"))
	Question=trim(request("Question"))
	Answer=trim(request("Answer"))
	Sex=trim(Request("Sex"))
	Email=trim(request("Email"))
	Homepage=trim(request("Homepage"))
	OICQ=trim(request("OICQ"))
	MSN=trim(request("MSN"))
	blogname=trim(request("blogname"))
	user_showlog_num=clng(trim(request("user_showlog_num")))
	user_showcomment_num=clng(trim(request("user_showcomment_num")))
	user_showmessage_num=clng(trim(request("user_showmessage_num")))
	user_shownewlog_num=clng(trim(request("user_shownewlog_num")))
	user_shownewcomment_num=clng(trim(request("user_shownewcomment_num")))
	user_shownewmessage_num=clng(trim(request("user_shownewmessage_num")))
	user_showlogword_num=trim(request("user_showlogword_num"))
	en_blogteam=request("en_blogteam")
	if not ot_user then
		if Password<>"" then
			if strLength(Password)>12 or strLength(Password)<6 then
				founderr=true
				errmsg=errmsg & "<br><li>密码不能大于12小于6，如果你不想修改密码，请保持为空。</li>"
			end if
			if Instr(Password,"=")>0 or Instr(Password,"%")>0 or Instr(Password,chr(32))>0 or Instr(Password,"?")>0 or Instr(Password,"&")>0 or Instr(Password,";")>0 or Instr(Password,",")>0 or Instr(Password,"'")>0 or Instr(Password,",")>0 or Instr(Password,chr(34))>0 or Instr(Password,chr(9))>0 or Instr(Password,"")>0 or Instr(Password,"$")>0 then
				errmsg=errmsg+"<br><li>密码中含有非法字符，如果你不想修改密码，请保持为空。</li>"
				founderr=true
			end if
		end if
		if Password<>PwdConfirm then
			founderr=true
			errmsg=errmsg & "<br><li>密码和确认密码不一致</li>"
		end if
		if Question="" then
			founderr=true
			errmsg=errmsg & "<br><li>密码提示问题不能为空</li>"
		end if
	end if
	if Sex="" then
		founderr=true
		errmsg=errmsg & "<br><li>性别不能为空</li>"
	else
		sex=cint(sex)
		if Sex<>0 and Sex<>1 then
			Sex=1
		end if
	end if
	if Email="" then
		founderr=true
		errmsg=errmsg & "<br><li>Email不能为空</li>"
	else
		if IsValidEmail(Email)=false then
			errmsg=errmsg & "<br><li>您的Email有错误</li>"
   			founderr=true
		end if
	end if
	if OICQ<>"" then
		if not isnumeric(OICQ) or len(cstr(OICQ))>10 then
			errmsg=errmsg & "<br><li>OICQ号码只能是4-10位数字，您可以选择不输入。</li>"
			founderr=true
		end if
	end if
	if MSN<>"" then
		if IsValidEmail(MSN)=false then
			errmsg=errmsg & "<br><li>你的MSN有误。</li>"
			founderr=true
		end if
	end if
	if request("usertype")="" then
		errmsg=errmsg & "<br><li>请选择你的blog分类。</li>"
		founderr=true
	end if
	if not isnumeric(user_showlogword_num) then
		errmsg=errmsg & "<br><li>日志默认显示字数只能是数字。</li>"
		founderr=true
	end if
	
	if not isnumeric(user_showlog_num) then
		errmsg=errmsg & "<br><li>每页显示日志数只能是数字。</li>"
		founderr=true
	elseif user_showlog_num<1 then
		errmsg=errmsg & "<br><li>每页显示日志数必须大于零。</li>"
		founderr=true	
	end if
	
	if not isnumeric(user_showcomment_num) then
		errmsg=errmsg & "<br><li>每页显示评论数只能是数字。</li>"
		founderr=true
	elseif  user_showcomment_num<1 then
		errmsg=errmsg & "<br><li>每页显示评论数必须大于零。</li>"
		founderr=true
	end if
	
	if not isnumeric(user_showmessage_num) then
		errmsg=errmsg & "<br><li>每页显示留言数只能是数字。</li>"
		founderr=true
	elseif user_showmessage_num<1 then
		errmsg=errmsg & "<br><li>每页显示留言数必须大于零。</li>"
		founderr=true
	end if
	
	if not isnumeric(user_shownewlog_num) then
		errmsg=errmsg & "<br><li>侧边条新日志数只能是数字。</li>"
		founderr=true
	elseif user_shownewlog_num<1 then
		errmsg=errmsg & "<br><li>侧边条新日志数必须大于零。</li>"
		founderr=true
	end if
	
	if not isnumeric(user_shownewcomment_num) then
		errmsg=errmsg & "<br><li>侧边条新评论数只能是数字。</li>"
		founderr=true
	elseif user_shownewcomment_num<1 then
		errmsg=errmsg & "<br><li>侧边条新评论数必须大于零。</li>"
		founderr=true
	end if
	
	if not isnumeric(user_shownewmessage_num) then
		errmsg=errmsg & "<br><li>侧边条新留言数只能是数字。</li>"
		founderr=true
	elseif user_shownewmessage_num<1 then
		errmsg=errmsg & "<br><li>侧边条新留言数必须大于零。</li>"
		founderr=true
	end if
	
	if founderr=true then
		exit sub
	end if
	
	Set rsUser=Server.CreateObject("Adodb.RecordSet")
	sqlUser="select * from [user] where userID=" & UserID
	rsUser.Open sqlUser,Conn,1,3
	if rsUser.bof and rsUser.eof then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>找不到指定的用户！</li>"
		rsUser.close
		set rsUser=nothing
		exit sub
	end if
	if Password<>"" then
		if ot_user then
			ot_conn.execute("update "&ot_usertable&" set "&ot_password&"='"&md5(Password)&"' where "&ot_username&"='"&username&"'")
		else
			rsUser("userPassword")=md5(Password)
		end if
	end if
	rsUser("Question")=Question
	rsUser("Answer")=Answer
	rsUser("Sex")=Sex
	rsUser("userEmail")=Email
	rsUser("Homepage")=HomePage
	rsUser("oicq")=OICQ
	rsUser("Msn")=MSN
	rsuser("blogname")=blogname
	rsuser("user_showlog_num")=user_showlog_num
	rsuser("user_showcomment_num")=user_showcomment_num
	rsuser("user_showmessage_num")=user_showmessage_num
	rsuser("user_shownewlog_num")=user_shownewlog_num
	rsuser("user_shownewcomment_num")=user_shownewcomment_num
	rsuser("user_shownewmessage_num")=user_shownewmessage_num
	rsuser("nickname")=trim(request("nickname"))
	rsuser("user_showlogword_num")=user_showlogword_num
	rsuser("usertypeid")=clng(trim(request("usertype")))
	rsuser("en_blogteam")=en_blogteam
	rsUser.update
	rsUser.Close
	set rsUser=nothing
	call CloseConn()
	if Password<>"" then  
		Response.Cookies("oblog")("UserName")=""
		Response.Cookies("oblog")("Password")=""
		Response.Cookies("oblog")("UserLevel")=0
		response.Redirect "user_login.asp"
	end if
	response.redirect "User_info.asp"
end sub



if CheckUserLogined()=true then
	set rsuser=conn.execute("select * from [user] where username='"&username&"'")
end if

if founderr=true then
	call WriteErrMsg(errmsg)
else
%>

<FORM name="Form1" action="User_info.asp" method="post">
  <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#FFFFFF" class="border">
    <tr> 
      <td height=22 colspan=2 align="center" class="title">修改我的blog信息</td>
    </tr>
    <tr class="tdbg" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#BFDFFF'"> 
      <td width="40%">用户id：</td>
      <td width="60%"><%=rsUser("userName")%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
    </tr>
    <tr class="tdbg" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#BFDFFF'"> 
      <td>昵称(可为中文)：</td>
      <td><input name=nickname   type=text id="nickname" value="<%=rsuser("nickname")%>" size=30 maxlength=20>
        (若为空则日志显示用户id)</td>
    </tr>
    <tr class="tdbg" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#BFDFFF'"> 
      <td>blog名：</td>
      <td><input name=blogname   type=text id="blogname" value="<%=rsuser("blogname")%>" size=30 maxlength=20></td>
    </tr>
    <tr class="tdbg" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#BFDFFF'"> 
      <td>blog类别：</td>
      <td><select name="usertype" id="usertype">
          <option value="<%if rsUser("usertypeid")<>"" then response.Write(rsUser("usertypeid"))%>" selected> 
          <%
		if rsUser("usertypeid")<>""  then
			dim rs
	 		set rs=conn.execute("select typename from usertype where id="&rsUser("usertypeid"))
	  		if not rs.eof then
	  		response.Write rs(0)	
	  		end if
	    else
	        response.Write "请选择"
	  	end if		
	  %>
          </option>
          <%
		set rs=conn.execute("select id,typename from usertype")
		do while not rs.eof  %>
          <option value=<%=rs(0)%>><%=rs(1)%></option>
          <%
			rs.movenext
		loop
		set rs=nothing  
	    %>
        </select></td>
    </tr>
    <tr class="tdbg" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#BFDFFF'">
      <td>是否允许其他人把我加入博客团队：</td>
      <td><input type=radio value="true" name=en_blogteam <%if rsUser("en_blogteam")="true" then response.write "CHECKED"%>>
        是 &nbsp;&nbsp; 
        <input type=radio value="false" name=en_blogteam <%if rsUser("en_blogteam")="false" then response.write "CHECKED"%>>
        否 </td>
    </tr>
    	<%if not ot_user then%>
	<tr class="tdbg" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#BFDFFF'"> 
      <td width="40%">密码(至少6位)：<br>
        请输入密码,若更改了密码需要重新登陆。</td>
      <td width="60%"> <input   type=password maxlength=16 size=30 name=Password> 
        <font color="#FF0000">如果不想修改，请留空</font> </td>
    </tr>
    <tr class="tdbg" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#BFDFFF'"> 
      <td>确认密码(至少6位)： </td>
      <td><input name=PwdConfirm   type=password id="PwdConfirm" size=30 maxlength=12> 
        <font color="#FF0000">如果不想修改，请留空</font> </td>
    </tr>

    <tr class="tdbg" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#BFDFFF'"> 
      <td width="40%">密码问题：<br> </td>
      <td width="60%"> <input name="Question"   type=text value="<%=rsUser("Question")%>" size=30> 
      </td>
    </tr>
    <tr class="tdbg" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#BFDFFF'"> 
      <td width="40%">问题答案：<br> </td>
      <td width="60%"> <input   type=text size=30 name="Answer"> <font color="#FF0000">如果不想修改，请留空</font></td>
    </tr>
	<%end if%>
    <tr class="tdbg" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#BFDFFF'"> 
      <td width="40%">性别：</td>
      <td width="60%"> <input type=radio value="1" name=sex <%if rsUser("Sex")=1 then response.write "CHECKED"%>>
        男 &nbsp;&nbsp; <input type=radio value="0" name=sex <%if rsUser("Sex")=0 then response.write "CHECKED"%>>
        女</td>
    </tr>
    <tr class="tdbg" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#BFDFFF'"> 
      <td width="40%">Email地址：</td>
      <td width="60%"> <input name=Email value="<%=rsUser("userEmail")%>" size=30   maxlength=50> 
      </td>
    </tr>
    <tr class="tdbg" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#BFDFFF'"> 
      <td width="40%">主页：</td>
      <td width="60%"> <input   maxlength=100 size=30 name=homepage value="<%=rsUser("Homepage")%>"></td>
    </tr>
    <tr class="tdbg" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#BFDFFF'"> 
      <td width="40%">OICQ号码：</td>
      <td width="60%"> <input name=OICQ value="<%=rsUser("oicq")%>" size=30 maxlength=20></td>
    </tr>
    <tr class="tdbg" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#BFDFFF'"> 
      <td width="40%">MSN：</td>
      <td width="60%"> <input name=msn value="<%=rsUser("Msn")%>" size=30 maxlength=50></td>
    </tr>
    <tr class="tdbg" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#BFDFFF'"> 
      <td>日志默认显示字数：</td>
      <td><input name="user_showlogword_num" type="text" id="user_showlogword_num" value="<%=rsUser("user_showlogword_num")%>" size="5">
        字(中文按两个字符计算)</td>
    </tr>
    <tr class="tdbg" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#BFDFFF'"> 
      <td width="40%">主页面调用日志条数：</td>
      <td width="60%"><input name="user_showlog_num" type="text" id="user_showlog_num" value="<%=rsUser("user_showlog_num")%>" size="5">
        条</td>
    </tr>
    <tr class="tdbg" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#BFDFFF'"> 
      <td>主页面调用回复条数：</td>
      <td><input name="user_showcomment_num" type="text" id="user_showcomment_num" value="<%=rsUser("user_showcomment_num")%>" size="5">
        条</td>
    </tr>
    <tr class="tdbg" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#BFDFFF'"> 
      <td>主页面调用留言条数：</td>
      <td><input name="user_showmessage_num" type="text" id="user_showmessage_num" value="<%=rsUser("user_showmessage_num")%>" size="5">
        条</td>
    </tr>
    <tr class="tdbg" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#BFDFFF'"> 
      <td>首页侧边条调用最新日志条数：</td>
      <td><input name="user_shownewlog_num" type="text" id="user_shownewlog_num" value="<%=rsUser("user_shownewlog_num")%>" size="5">
        条</td>
    </tr>
    <tr class="tdbg" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#BFDFFF'"> 
      <td>首页侧边条调用最新回复条数：</td>
      <td><input name="user_shownewcomment_num" type="text" id="user_shownewcomment_num" value="<%=rsUser("user_shownewcomment_num")%>" size="5">
        条</td>
    </tr>
    <tr class="tdbg" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#BFDFFF'"> 
      <td>首页侧边条调用最近留言条数：</td>
      <td><input name="user_shownewmessage_num" type="text" id="user_shownewmessage_num" value="<%=rsUser("user_shownewmessage_num")%>" size="5">
        条</td>
    </tr>
    <tr class="tdbg" > 
      <td height="40" colspan="2" align="center"><input name="Action" type="hidden" id="Action" value="SaveModify"> 
        <input name=Submit   type=submit id="Submit" value="保存修改结果"> <input name="UserID" type="hidden" id="UserID" value="<%=rsUser("userID")%>"></td>
    </tr>
  </table>
</form>
<%end if%>
