<!--#include file="../conn.asp"-->
<!--#include file="../inc/md5.asp"-->
<!--#include file="../inc/function.asp"-->
<%
dim id,rs,rs1
dim userid,gradename,zscore,grade,GradeTypename,Regtime,pai,sex,face,skinpath,lastip,lasttime,qq,msn,tel,nicheng,info,truename,usermail,UserType,isopen
id=Trim(Request.QueryString("id"))
IF id="0" or not isnumeric(id) Then Response.Redirect("../")
Dim AskD
Set AskD = Server.CreateObject("KwAsk.FunAsk")
	opendb
	set AskD.myConn =conn
	AskD.myPredb =predb
	AskD.Getsetting()
	AskD.GetUserRole()
	siteinfo=AskD.siteinfo
	setting=AskD.setting
    UserRole=AskD.UserRole
	regForm=AskD.regForm
	
IF id<>Request.Cookies("Muser") and Request.Cookies("Muser")<>"" and request.Cookies("Visitor")<>id then
   conn.execute("delete from "&predb&"Visitor where toid="&id&" and fromid="&Request.Cookies("Muser"))
   conn.execute("insert into "&predb&"Visitor(toid,fromid,ftime) values("&id&","&Request.Cookies("Muser")&",'"&now()&"')")
   response.Cookies("Visitor")=id
End IF

Set rs=conn.execute("select *,(select count(id)+1 from "&predb&"user b where b.score>a.score) as pai from "&predb&"user a where id="&id)
    userid=rs("userid")
	UserType=rs("UserType")
	qq=rs("qq")
	msn=rs("msn")
	tel=rs("tel")
	nicheng=rs("nicheng")
	info=rs("info")
	truename=rs("truename")
	usermail=rs("usermail")
	isopen=rs("isopen")
	sex=rs("sex")
	Regtime=rs("Regtime")
	grade=rs("grade")
	IF rs("face")&""<>"" Then face=rs("face") else face="Face/info.gif"
	zscore=rs("score")
	pai=rs("pai")
	skinpath=rs("skinpath")
	IF  skinpath&""="" Then skinpath=siteInfo(16)
		  if rs("gradetype")=0 then
		      set rs1=conn.execute("select gradename,GradeTypename from "&predb&"UserGrade a inner join "&predb&"UserGradeType b on b.id=a.GradeTypeId where b.isDefault=1 and a.grade="&rs("grade"))
		  else
		      set rs1=conn.execute("select gradename,GradeTypename from "&predb&"UserGrade a inner join "&predb&"UserGradeType b on b.id=a.GradeTypeId where b.id="&rs("gradetype")&" and a.grade="&rs("grade"))
		  end if
		     gradename=rs1("gradename")
			 GradeTypename=rs1("GradeTypename")
			 set rs1=nothing
	lastip=rs("lastip")
	lasttime=rs("lasttime")
set rs=nothing
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><%= userid %> - 个人中心</title>
<link href="Images/<%=skinpath%>/style.css" rel="stylesheet" type="text/css" />
<script language="javascript" src="../inc/AjaxUpop.js"></script>
<script language="javascript" src="../js/msg.js"></script>
<script language="javascript">
function cthis(n)
{
	for(i=0;i<4;i++)
	{
	document.getElementById('mm'+i).className = 'mid-t4';
	}
	
	document.getElementById('mm'+n).className = 'mid-t3';
	AjaxUpop(n,<%= id %>,1);
}

function showuc()
{
	if(document.getElementById('uc').style.display=='none')
	{
	document.getElementById('uc').style.display='block';
	}
	else
	{
	document.getElementById('uc').style.display='none';
	}
}
</script>
</head>
<body>
<div class="mainbox">
<div class="meun">
    <div class="m-l"><img src="Images/<%=skinpath%>/logo.gif" /></div>
    <div class="m-r"><% If request.Cookies("Muser")<>"" Then %><font color="#000000">您好，</font><a href="userinfo.asp?id=<%= request.Cookies("Muser") %>"><%= request.Cookies("Musername") %></a> | <a href="Loginout.asp">退出</a> | <% Else %><a href="login.asp">登录</a> | <a href="reg.asp">注册</a> | <% End If %><a href="../">知道首页</a></div>
</div>
<div class="top">
   <div class="top1">
     <div class="top_l">
        <div class="top_font"><%= userid %>的个人中心</div>
     </div>
     <div class="top_r"></div>
   </div>
</div>
<div class="control">
  <div class="uc0"><% If id=Request.Cookies("Muser") Then %><img src="Images/<%=skinpath%>/control.gif" alt="个人管理" align="absmiddle"/> <a href="javascript:showuc()">个人管理</a><% End If %></div>
  <div id="uc" class="ucontr" style="display:none">
    <div class="uc1"><a href="javascript:showuc()">r</a></div>
    <div class="uc2" onmouseover="this.className='uc3'" onmouseout="this.className='uc2'"><img src="Images/<%=skinpath%>/dot1.gif" align="absmiddle" alt=""/> <a href="javascript:showuc();openWindow('UserControl.asp?act=1&id=<%= id %>', '400', '480', '修改个人资料');">修改个人资料</a></div>
    <div class="uc2" onmouseover="this.className='uc3'" onmouseout="this.className='uc2'"><img src="Images/<%=skinpath%>/dot3.gif" align="absmiddle" alt=""/> <a href="javascript:showuc();openWindow('UserControl.asp?act=2&id=<%= id %>', '462', '528', '定制页面模板','yes');">定制页面模板</a></div>
    <div class="uc2" onmouseover="this.className='uc3'" onmouseout="this.className='uc2'"><img src="Images/<%=skinpath%>/m_r.gif" align="absmiddle" alt=""/> <a href="javascript:showuc();openWindow('UserControl.asp?act=3&id=<%= id %>', '462', '528', '我的收件箱');">我的收件箱</a></div>
    <div class="uc2" onmouseover="this.className='uc3'" onmouseout="this.className='uc2'"><img src="Images/<%=skinpath%>/m_s.gif" align="absmiddle" alt=""/> <a href="javascript:showuc();openWindow('UserControl.asp?act=44&id=<%= id %>', '560', '352', '我要发信息');">我要发信息</a></div>
    <div class="uc2" onmouseover="this.className='uc3'" onmouseout="this.className='uc2'"><img src="Images/<%=skinpath%>/dot5.gif" align="absmiddle" alt=""/> <a href="javascript:showuc();openWindow('UserControl.asp?act=5&id=<%= id %>', '300', '138', '修改密码');">修改密码</a></div>
  </div>
</div>
<div class="mid">

  <div class="mid-l">
  <%
  dim s
  s=Trim(Request.QueryString("s"))
  select case s
    case "1"
	   call left1()
	case "2"
	   call left2()
	case "3"
	   call left3()
	case else
	   call left0()
  end select
  
  sub left0()
  %>
    <div class="mid-t"><img src="Images/<%=skinpath%>/t-bg.gif" alt="" align="absmiddle"/>问答</div>
    <div class="minfo">
        <ul>
            <li>头衔：<%= gradename %></li>
			<li>等级：<%= grade %>级</li>
            <li>等级方案：<%= GradeTypename %></li>
			<li>积分：<%= zscore %>分&nbsp; &raquo;<a href="?id=<%= id %>&s=2">积分明细</a></li>
            <li>排名：<% If pai>500 Then %>尚未进入总排名<% Else Response.Write("第"&pai&"名") End If %></li>
        </ul>
    </div>
    
    <div class="mid-t2">
      <div onclick="cthis(0)" id="mm0" class="mid-t4">我的提问</div>
      <div onclick="cthis(1)" id="mm1" class="mid-t3">我的回答</div>
      <div onclick="cthis(2)" id="mm2" class="mid-t4">我的投票</div>
      <div onclick="cthis(3)" id="mm3" class="mid-t4">我的关注</div>
    </div>
    
    <div id="upop">
    <div class="mol">
      <div class="mol1">
      <div class="m1"><strong>分类</strong></div>
      <div class="m2"><strong>标题</strong></div>
      <div class="m3"><strong>状态</strong></div>
      <div class="m4"><strong>提问时间</strong></div>
      <div class="m5"><strong>回答数</strong></div>
      <div class="m6"><strong>删除</strong></div>
      </div>
      <div class="mol1">
      <div class="m1"></div>
      <div class="m2">点击上栏查看相关问题</div>
      <div class="m3"></div>
      <div class="m4"></div>
      <div class="m5"></div>
      <div class="m6"></div>
      </div>
    </div>
    <div class="mend"><a href="../myAsk.asp">我要提问>></a></div>
    </div>
    <%
  end sub
	
  sub left1()
  %>
    <div class="mid-t"><img src="Images/<%=skinpath%>/t-bg.gif" alt="" align="absmiddle"/>个人介绍</div>
	<div></div>
	<div class="mid-t2">
      <div onclick="cthis(1)" id="mm1" class="mid-t3">详细资料</div>
    </div>
	<%
	if isopen=1 then
	   Response.Write("<div class=""i2""><p>&nbsp;</p><p>该用户资料不公开</p></div>")
	   exit sub
	end if
	%>
    <div class="i1">基本资料</div>
	<div class="i2">
        <ul>
		<li>UserID：<%= userid %></li>
		<li>昵称：<%= nicheng %></li>
		<li>性别：<%= sex %></li>
		<li>登陆IP：<%= lastip %></li>
		<li>注册时间：<%= regtime %></li>
		<li>登陆时间：<%= lasttime %></li>
		<li>QQ：<%= qq %></li>
		<li>MSN：<%= msn %></li>
		<li>电话：<%= tel %></li>
		<li>真实姓名：<%= truename %></li>
		<li>电邮：<%= usermail %></li>
		</ul>
	</div>
	<div class="i1">个人简介</div>
	<div class="i2"><%= info %></div>
    <%
	end sub
	
    sub left2()
  %>
    <div class="mid-t"><img src="Images/<%=skinpath%>/t-bg.gif" alt="" align="absmiddle"/>个人积分明细</div>
	<div></div>
	<div class="mid-t2">
      <div onclick="cthis(1)" id="mm1" class="mid-t3">积分明细</div>
    </div>
	<div class="i2">
	    <div class="d1"><strong>积分事项</strong></div>
		<div class="d2"><strong>分值</strong></div>
		<div class="d3"><strong>积分时间</strong></div>
		<div class="d4"><strong>惩罚详细</strong></div>
	</div>
	<%
	Dim page,maxperpage,minid,n,idcount
	maxperpage=25
	page=clng(Request.QueryString("page"))
	
	set rs=conn.execute("select count(id) from "&predb&"Details where uid="&id&" and DateDiff("&Sday&",addtime,'"&now()&"')<=30")
	idcount=rs(0)
	set rs=nothing
	
		If idcount Mod maxperpage = 0 Then
			n = idcount \ maxperpage
		else
			n = idcount \ maxperpage + 1
		end If
		
        IF page>n then page=n
        IF page<1 then page=1
		
		if page=1 then
           set rs=conn.execute("select top "&maxperpage&" * from "&predb&"Details where uid="&id&" and DateDiff("&Sday&",addtime,'"&now()&"')<=30 order by id desc")
		else
			set rs=conn.execute("select min(id) from (select top "&(page-1)*maxperpage&" id from "&predb&"Details where uid="&id&" and DateDiff("&Sday&",addtime,'"&now()&"')<=30 order by id desc) d")
			minid=rs(0)
			set rs=nothing
           set rs=conn.execute("select top "&maxperpage&" * from "&predb&"Details where id<"&minid&" and uid="&id&" and DateDiff("&Sday&",addtime,'"&now()&"')<=30 order by id desc")
		end if

	do while not rs.eof
	%>
	<div class="i2">
	    <div class="d1"><%= rs("mtitle") %></div>
		<div class="d2"><%= rs("fenz") %></div>
		<div class="d3"><%= rs("addtime") %></div>
		<div class="d4"><a href="#">详细 &raquo;</a></div>
	</div>
    <%
	rs.movenext
	loop
	set rs=nothing
	%>
	<div class="i2">共<b><%= idcount %></b>则 分<font color="#FF0000"><%= page %>/<%= n %></font>页&nbsp;&nbsp; <a href="?id=<%= id %>&s=2&page=1">首页</a>&nbsp;&nbsp; <a href="?id=<%= id %>&s=2&page=<%= page-1 %>">上一页</a>&nbsp;&nbsp; <a href="?id=<%= id %>&s=2&page=<%= page+1 %>">下一页</a>&nbsp;&nbsp; <a href="?id=<%= id %>&s=2&page=<%= n %>">尾页</a></div>
	<%
	end sub
	
sub left3()
	If ID<>Request.Cookies("Muser") Then Response.Redirect("?")
	Dim zclass,sZclass,pstr,i,classname,Ynum
	set rs=conn.execute("select zclass from "&predb&"user where id="&id)
	    Zclass=rs("zclass")
	set rs=nothing
	
	set rs=conn.execute("select classname from "&predb&"class where classid in("&Zclass&")")
	    do while not rs.eof
		classname=classname&"<u>"&rs("classname")&"</u> &nbsp;"
		rs.movenext
		loop
	set rs=nothing
	
	IF Zclass&""="" Then Zcalss=0
	
	IF Instr(Zclass,",")>0 Then
	   sZclass=split(zclass,",")
	   for i=0 to ubound(sZclass)
	      pstr=pstr&" or ' '+ParentStr+',' like '%"&" "&sZclass(i)&","&"%' "
	   next
	else
	      pstr=" or ' '+ParentStr+',' like '%"&" "&Zclass&","&"%' "
	End IF
	
	Dim page,maxperpage,minid,n,idcount
	maxperpage=25
	page=clng(Request.QueryString("page"))
        set rs=conn.execute("select count(askid) from "&predb&"ask a inner join "&predb&"class b on a.sclass=b.classid where a.sclass in("&zclass&") "&pstr&"")
		idcount=rs(0) 
		set rs=nothing
		If idcount Mod maxperpage = 0 Then
			n = idcount \ maxperpage
		else
			n = idcount \ maxperpage + 1
		end If
		
        IF page>n then page=n
        IF page<1 then page=1

		if page=1 then
           set rs=conn.execute("select top "&maxperpage&" askid,title,asktime,ansnum,classid,classname,ispass,state from "&predb&"ask a inner join "&predb&"class b on a.sclass=b.classid where a.sclass in("&zclass&") "&pstr&" order by askid desc")
		else
			set rs=conn.execute("select min(askid) from (select top "&(page-1)*maxperpage&" askid from "&predb&"ask a inner join "&predb&"class b on a.sclass=b.classid where a.sclass in("&zclass&")"&pstr&" order by askid desc) d")
			minid=rs(0)
			set rs=nothing
           set rs=conn.execute("select top "&maxperpage&" askid,title,asktime,ansnum,classid,classname,ispass,state from "&predb&"ask a inner join "&predb&"class b on a.sclass=b.classid where askid<"&minid&" and (a.sclass in("&zclass&")"&pstr&") order by askid desc")
		end if
   %>
    <div class="mid-t"><img src="Images/<%=skinpath%>/t-bg.gif" alt="" align="absmiddle"/>专家管理</div>
	<div></div>
	<div class="mid-t2">
      <div onclick="cthis(1)" id="mm1" class="mid-t3">管理问答</div>
	</div>
    <div id="upop">
    <div>专家分类：<%= classname %></div>
    <div class="mol">
      <div class="mol1">
      <div class="m1"><strong>分类</strong></div>
      <div class="m2"><strong>标题</strong></div>
      <div class="m3"><strong>状态</strong></div>
      <div class="m4"><strong>提问时间</strong></div>
      <div class="m7"><strong>操作</strong></div>
      </div>
      <%
	  do while not rs.eof
	  
	IF rs("isPass")=0 then
	   Ynum=75
	Else
	select case rs("state")
	case 0
	   Ynum=120
	case 1
	   Ynum=45
	case 2
	   Ynum=150
	case 3
	   Ynum=135
	case 4
	   Ynum=90
	case 5
	   Ynum=60
	case 6
	   Ynum=30
	case 7
	   Ynum=15
	end select
	End IF
	  %>
      <div class="mol1">
      <div class="m1"><a href="../<% IF setting(34)=0 Then %>list.asp?classid=<%= rs("classid") %><% Else %><%= siteInfo(1) %>list-<%= rs("classid") %>.html<% End If %>" target="_blank"><%= AskD.leftstr(rs("classname"),8) %></a></div>
      <div class="m2"><a href="../<% IF setting(34)=0 Then %>ask.asp?id=<%= rs("askid") %><% Else %><%= siteInfo(1) %>ask-<%= rs("askid") %>.html<% End If %>" target="_blank"><%= AskD.leftstr(rs("title"),38) %></a></div>
      <div class="m3" style="background-image: url(../images/state.gif);height:15px;width:90px;background-position: center <%= Ynum %>px;background-repeat: repeat-y;margin-top: 6px;"></div>
      <div class="m4"><%= rs("asktime") %></div>
      <div class="m7"><a href="javascript:openWindow('UserControl.asp?act=zhuancn&id=<%= id %>&askid=<%= rs("askid") %>', '462', '528', '专家管理问题','yes');">管理</a> <a href="javascript:openWindow('UserControl.asp?act=zhuansh&id=<%= id %>&askid=<%= rs("askid") %>', '300', '120', '专家审核提问');" onclick="return confirm('确认审核或撤销问题吗?')"><% If rs("ispass")=0 Then %><font color="#0000FF">待审</font><% Else %>撤审<% End If %></a></div>
      </div>
      <%
	  rs.movenext
	  loop
	  set rs=nothing
	  %>
      <div></div>
      <div>共<b><%= idcount %></b>则 分<font color="#FF0000"><%= page %></font>/<%= n %>页&nbsp;&nbsp; <a href="?id=<%= id %>&s=3&page=1">首页</a>&nbsp;&nbsp; <a href="?id=<%= id %>&s=3&page=<%= page-1 %>">上一页</a>&nbsp;&nbsp; <a href="?id=<%= id %>&s=3&page=<%= page+1 %>">下一页</a>&nbsp;&nbsp; <a href="?id=<%= id %>&s=3&page=<%= n %>">尾页</a></div>
    </div>
    </div>
	<%
	end sub
	%>
	
	
  </div>
  
  <div class="mid-r">
      <div class="mrls">
        <div class="mid-t"><img src="Images/<%=skinpath%>/t-bg.gif" alt="" align="absmiddle"/>个人信息</div> 
        <div class="mid-p"><img src="../UploadFile/<%= face %>" width="116" height="120"/></div>
        <div class="mid-p2"><%= userid %>[<%= sex %>]</div>
        <div class="mid-p3">等级：<%= gradename %></div>
        <% If id=Request.Cookies("Muser") Then %>
        <div class="mid-p3"><img src="Images/<%=skinpath%>/m_r.gif" /> <a href="javascript:openWindow('UserControl.asp?act=3&id=<%= id %>', '462', '528', '我的收件箱');">我的收件箱</a>
        <%
		set rs=conn.execute("select count(id) from "&predb&"message where (touser='"&id&"' or touser='0' or ','+touser like '%,"&id&",%') and id not in(select id from "&predb&"message where ','+delu like '%,"&id&",%')")
		Response.Write("["&rs(0)&"]")
		set rs=nothing
		%>
        </div>
        <% Else %>
        <div class="mid-p3"><img src="Images/<%=skinpath%>/m_s.gif" /> <a href="javascript:openWindow('UserControl.asp?act=4&id=<%= id %>', '560', '338', '发送消息');">发送消息</a></div>
        <% End If %>
        <div class="mid-p4"><% If s="" Then %><a href="?id=<%= id %>&s=1">详细资料</a><% Else %><a href="?id=<%= id %>">基本资料</a><% End If %>
		<% If UserType=1 Then %>
           <img src="images/zhuan.gif" />
           <% If ID=Request.Cookies("Muser") Then %><a href="?id=<%= id %>&s=3">专家管理</a><% End If %>
        <% End If %>
        </div>
      </div>
      <div class="br"></div>
      <div class="mrls">
        <div class="mid-t"><img src="Images/<%=skinpath%>/t-bg.gif" alt="" align="absmiddle"/>最近访客</div> 
		<%
		set rs=conn.execute("select top 10 a.id,a.userid,b.ftime from "&predb&"user a inner join "&predb&"Visitor b on a.id=b.fromid where b.toid="&id&" order by b.id desc")
		if rs.bof and rs.eof then
		%>
		<div class="vis">暂无访客</div>
		<%
		else
		do while not rs.eof
		%>
        <div class="vis"><a href="userinfo.asp?id=<%= rs("id") %>" target="_blank"><%= rs("userid") %></a> (<%= formatdatetime(rs("ftime"),vbshortdate) %>)</div>
		<%
		rs.movenext
		loop
		end if
		set rs=nothing
		%>
      </div>
  </div>
</div>
  <div class="end">
        <div class="end-link"><%= RexHtml(GetDaohang(2)) %></div>
        <div class="line"></div>
        <div class="end-copy"><%= RexHtml(siteInfo(15)) %></div>
  </div>
</div>
<%
set AskD.myConn =Nothing
closedb
Set AskD = Nothing
%>
</body>
</html>
