<!--#include file="conn.asp"-->
<!--#include file="inc/const.asp"-->
<!--#include file="inc/dv_clsother.asp"-->
<%
Dim TemplateStr,dhy_rs,dhy_sql,dhy_name,dhy_user,dhy_user_sm,dhy_photo,dhy_width,dhy_height,dhy_gg,dhy_new_yn,dhy_click_yn,dhy_new_num,dhy_click_num,dhy_no_num,dhy_num,dhy_file_count,dhy_click_count,dhy_add_time,rs,sql,usID,i,tmid,ctmid,crs
Dvbbs.LoadTemplates("")
TemplateStr="<tr><td class={$BgColor}><li>{$VarName}&nbsp;{$VarDesc}</td><td class={$BgColor}>&nbsp;当前值：<font color="&Dvbbs.MainSetting(1)&"><b>{$VarValue}</b></font></td></tr>"
if Request.ServerVariables("Query_String")="" and not Dvbbs.Founduser then
   errs("您还没有<a href=login.asp>登录论坛</a>，不能申请个人主页。如果您还没有<a href=reg.asp>注册</a>，请先<a href=reg.asp>注册</a>！")
elseif Request.ServerVariables("Query_String")<>"" then
   usID=request("usID")
   if usID="" or not isnumeric(usID) then errs("请勿从外部提交数据！")
elseif Dvbbs.Founduser then
   usID=dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userid").text
end if
set dhy_rs =Dvbbs.Execute("select site_name,user,userphoto,width,height,user_sm,index_gg,new_list_yn,new_list_num,click_list_yn,click_list_num,file_list_num,file_no_num,file_num,click_num,add_time,yn from [dhy_index] where userID="&usID)
if dhy_rs.eof then
   dhy_rs.close:set dhy_rs=nothing
   errs("还没有申请建立自己的个人主页！<a href=dhy_reg.asp>我要申请</a>")
elseif dhy_rs("yn")=0 then
   dhy_rs.close:set dhy_rs=nothing
   errs("该个人主页已被管理员锁定或正在申核中...")
elseif dhy_rs("yn")=2 then
   dhy_rs.close:set dhy_rs=nothing
   errs("该个人主页已被删除，如有疑问请<a href=mailto:"&Dvbbs.Forum_Info(5)&">联系管理员</a>")
end if
dhy_name=dhy_rs("site_name")
dhy_user=dhy_rs("user")
dhy_photo=dhy_rs("userphoto")
dhy_width=dhy_rs("width")
dhy_height=dhy_rs("height")
dhy_user_sm=dhy_rs("user_sm")
dhy_gg=dhy_rs("index_gg")
dhy_new_yn=dhy_rs("new_list_yn")
dhy_click_yn=dhy_rs("click_list_yn")
dhy_new_num=dhy_rs("new_list_num")
dhy_click_num=dhy_rs("click_list_num")
dhy_num=dhy_rs("file_list_num")
dhy_no_num=dhy_rs("file_no_num")
dhy_file_count=dhy_rs("file_num")
dhy_click_count=dhy_rs("click_num")
dhy_add_time=dhy_rs("add_time")
dhy_rs.close:set dhy_rs=nothing
Dvbbs.Stats="<a href=dhy_list.asp>个人主页系统</a> → <a href=?usID="&usID&">"&dhy_name&"</a>"
Dvbbs.Nav()
Dvbbs.Head_var 2,0,"",""
set rs=Dvbbs.Execute("select fileid from [dhy_file]")
do while not rs.eof
if tmid="" then
   tmid=rs("fileID")
else
   tmid=tmid&","&rs("fileID")
end if
rs.movenext()
loop
rs.close:set rs=nothing
if tmid="" then tmid=0
call dhy_index()
Dvbbs.Execute("update [dhy_index] set click_num=click_num+1 where userID="&usID)
Dvbbs.ActiveOnline()
Dvbbs.Footer()

function errs(str)
Response.redirect "showerr.asp?ErrCodes=<li>"&str&"&action=OtherErr"
end function

function topinfo(str)
Response.Write "<table style=width:100% cellpadding=4 cellspacing=1 align=center class=tableborder1 style=word-break:break-all><tr><th colspan=2>"&str&"</th></tr></table>"
end function

public sub dhy_index()
Response.Write "<table cellpadding=0 cellspacing=0 align=center class=tableborder1 style=word-break:break-all>"
response.write "<tr>"
response.write "<td width=28% class=tablebody2 valign=top>"
topinfo("作者简介")
Response.Write "<table style=width:100% cellpadding=3 cellspacing=1 class=tableborder1 style=word-break:break-all>"
response.write "<tr><td class=tablebody1>"
dim writes
if len(dhy_photo)=0 then
writes=dhy_user_sm
else
writes=writes&"<table style=width:100% cellpadding=3 cellspacing=0 class=tableborder1 style=word-break:break-all>"
writes=writes&"<tr>"
writes=writes&"<td class=tablebody1 width="&dhy_width&" >"
writes=writes&"<img src='"&dhy_photo&"' width="&dhy_width&" height="&dhy_height&">"
writes=writes&"</td>"
writes=writes&"<td class=tablebody1>"
writes=writes&dhy_user_sm
writes=writes&"</td>"
writes=writes&"</tr>"
writes=writes&"</table>"
end if
response.write writes
response.write "</td></tr></table>"
if Dvbbs.Founduser then
   if usID=dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userid").text then
      topinfo("站长管理")
      Response.Write "<table style=width:100% cellpadding=4 cellspacing=1 class=tableborder1 style=word-break:break-all>"
      response.write "<tr><td class=tablebody1>"
      Response.Write "<table style=width:100% cellpadding=4 cellspacing=0 class=tableborder1 style=word-break:break-all>"
      response.write "<tr>"
      response.write "<td class=tablebody1><center><a href=dhy_admin.asp?action=main>基本信息</a></td>"
      response.write "<td class=tablebody1><center><a href=dhy_admin.asp?action=msm>资料修改</a></td>"
      response.write "<td class=tablebody1><center><a href=dhy_admin.asp?action=bulletin>公告管理</a></td>"
      response.write "</tr>"
      response.write "<tr>"
      response.write "<td class=tablebody1><center><a href=dhy_admin.asp?action=links>友情连接</a></td>"
      response.write "<td class=tablebody1><center><a href=dhy_admin.asp?action=fileclass>文章分类</a></td>"
      response.write "<td class=tablebody1><center><a href=dhy_admin.asp?action=add>文章添加</a></td>"
      response.write "</tr>"
      response.write "</table>"
      response.write "</td></tr></table>"
	end if
end if
topinfo("公告")
Response.Write "<table style=width:100% cellpadding=4 cellspacing=1 class=tableborder1 style=word-break:break-all>"
response.write "<tr><td class=tablebody1>"
response.write dhy_gg
response.write "</td></tr></table>"
if dhy_new_yn=1 then
topinfo("最新文章 TOP10")
Response.Write "<table style=width:100% cellpadding=0 cellspacing=1 class=tableborder1 style=word-break:break-all>"
set rs=Dvbbs.Execute("select TopicID,title,postuserName,hits,child,DateAndTime from [Dv_Topic] where TopicID in ("&tmid&") and postuserid="&usID&" order by DateAndTime desc")
response.write "<tr><td class=tablebody1>"
   Response.Write "<table style=width:100% cellpadding=4 cellspacing=0 class=tableborder1 style=word-break:break-all>"
   for i=1 to dhy_new_num
   if not rs.eof then
      response.write "<tr><td class=tablebody1 width=1% valign=top><li></td>"
	  response.write "<td class=tablebody1><a href=dhy_disp.asp?ID="&rs("TopicID")&"&usID="&usID&" title=标题&nbsp;"&rs("title")&"&#13;作者&nbsp;"&rs("postuserName")&"&#13;时间&nbsp;"&formatdatetime(rs("DateAndTime"),1)&"&#13;人气&nbsp;"&rs("hits")&"&#13;回复&nbsp;"&rs("child")&">"&rs("title")&"</a></td>"
	  response.write "</tr>"
      rs.movenext()
   else
      response.write "<tr><td class=tablebody1 width=1% valign=top><li></td>"
	  response.write "<td class=tablebody1><font color=#aaaaaa>未找到任何文章</font><br></td></tr>"
   end if
   next
   rs.close:set rs=nothing
   response.write "</table>"
response.write "</td></tr></table>"
end if
if dhy_click_yn=1 then
topinfo("人气文章 TOP10")
Response.Write "<table style=width:100% cellpadding=0 cellspacing=1 class=tableborder1 style=word-break:break-all>"
set rs=Dvbbs.Execute("select TopicID,title,postuserName,hits,child,DateAndTime from [Dv_Topic] where TopicID in ("&tmid&") and postuserid="&usID&" order by hits desc")
response.write "<tr><td class=tablebody1>"
   Response.Write "<table style=width:100% cellpadding=4 cellspacing=0 class=tableborder1 style=word-break:break-all>"
   for i=1 to  dhy_click_num
   if not rs.eof then
      response.write "<tr><td class=tablebody1 width=1% valign=top><li></td>"
	  response.write "<td class=tablebody1><a href=dhy_disp.asp?ID="&rs("TopicID")&"&usID="&usID&" title=标题&nbsp;"&rs("title")&"&#13;作者&nbsp;"&rs("postuserName")&"&#13;时间&nbsp;"&formatdatetime(rs("DateAndTime"),1)&"&#13;人气&nbsp;"&rs("hits")&"&#13;回复&nbsp;"&rs("child")&">"&rs("title")&"</a></td>"
	  response.write "</tr>"
      rs.movenext()
   else
      response.write "<tr><td class=tablebody1 width=1% valign=top><li></td>"
	  response.write "<td class=tablebody1><font color=#aaaaaa>未找到任何文章</font><br></td></tr>"
   end if
   next
   rs.close:set rs=nothing
   response.write "</table>"
response.write "</td></tr></table>"
end if
topinfo("主页信息")
Response.Write "<table style=width:100% cellpadding=4 cellspacing=1 class=tableborder1 style=word-break:break-all>"
response.write "<tr><td class=tablebody1>"
response.write "[主页名称]　<a href=?usID="&usID&">"&dhy_name&"</a><br>"
response.write "[作者名称]　<a href=dispuser.asp?ID="&usID&">"&dhy_user&"</a><br>"
response.write "[建站日期]　"&formatdatetime(dhy_add_time,1)&"<br>"
response.write "[文章数量]　"&dhy_file_count&" 篇<br>"
response.write "[访问次数]　"&dhy_click_count&" 人次<br>"
response.write "</td></tr></table>"
response.write "</td>"
response.write "<td class=tablebody1>."
response.write "</td>"
response.write "<td class=tablebody1 valign=top>"
topinfo(dhy_user&"-文章列表")
Response.Write "<table style=width:100% cellpadding=4 cellspacing=1 class=tableborder1 style=word-break:break-all>"
dim cid
cid=request("cid")
if not isnumeric(cid) then  errs("请勿从外部提交数据！")
if cid<>"" then
   set rs = Dvbbs.Execute("select id,userid,class_name from [dhy_class] where userid="&usID&" and yn=1 and id="&cid&" order by id")
else
   set rs = Dvbbs.Execute("select id,userid,class_name from [dhy_class] where userid="&usID&" and yn=1 order by id")
end if
do while not rs.eof
   response.write "<tr><td class=tablebody2 colspan=4><li><a href=?usID="&usID&"&cid="&rs("id")&" title=查看该分类下所有文章><b>["&rs("class_name")&"]</b></a></td></td></tr>"
   set crs=Dvbbs.Execute("select fileid from [dhy_file] where FileClass="&rs("id"))
   do while not crs.eof
   if ctmid="" then
      ctmid=crs("fileID")
   else
      ctmid=ctmid&","&crs("fileID")
   end if
   crs.movenext()
   loop
   crs.close:set crs=nothing
   if ctmid="" then ctmid=0
   set dhy_rs=Dvbbs.Execute("select TopicID,title,postuserName,hits,child,DateAndTime from [DV_Topic] where PostUserID="&usID&" and TopicID in ("&ctmid&") order by DateAndTime desc")
   ctmid=""
   if cid<>"" then
      dhy_num=dhy_no_num
   end if
   for i=1 to  dhy_num
   if not dhy_rs.eof then
      response.write "<tr>"
	  response.write "<td class=tablebody1><a href=dhy_disp.asp?ID="&dhy_rs("TopicID")&"&usID="&usID&">"&dhy_rs("Title")&"</a></td>"
	  response.write "<td class=tablebody1><center>"&dhy_rs("Child")&"</td>"
	  response.write "<td class=tablebody1><center>"&dhy_rs("Hits")&"</td>"
	  response.write "<td class=tablebody1><center>"&dhy_rs("DateAndTime")&"</td>"
	  response.write "</tr>"
      dhy_rs.movenext()
	end if
	next
    dhy_rs.close:set dhy_rs=nothing
rs.movenext()
loop
rs.close:set rs=nothing
response.write "</td></tr></table>"
response.write "</td>"
response.write "</tr>"
response.write "</table>"
Response.Write "<br><table cellpadding=4 cellspacing=1 align=center class=tableborder1 style=word-break:break-all><tr><th colspan=2>友情连接</th></tr></table>"
Response.Write "<table cellpadding=2 cellspacing=1 align=center class=tableborder1 style=word-break:break-all>"
response.write "<tr><td class=tablebody1>"
response.write Getlinks()
response.write "</td></tr></table>"
end sub

function Getlinks()
dim c,row_num,links
set rs=Dvbbs.Execute("select * from [dhy_link] where userid="&usID&" and islogo=1")
	c=1
	row_num=6
	links="<table width=100% >"
	do while not rs.eof
	if (c mod row_num)=1 then
	links=links&"<tr>"
	end if
	links=links&"<td class=tablebody1><center><a href='"&rs("url")&"'><img src="&rs("logo")&" border=0 alt="&rs("boardname")&"&#13;"&rs("readme")&"></a></td>"
    if (c mod row_num)=0 then
	links=links&"</tr>"
	end if
	c=c+1
	rs.MoveNext()
	loop
	links=links&"</tr>"
	links=links&"</table>"
rs.close:set rs=nothing
set rs=Dvbbs.Execute("select * from [dhy_link] where userid="&usID&" and islogo=0")
if not rs.eof then
links=links&"<table class=tableborder1 style=width:95% cellspacing=0 cellpadding=0 align=center border=0>"
links=links&"<tr><td></td></tr></table>"
end if
	c=1
	row_num=6
	links=links&"<table style=width:95% align=center >"
	do while not rs.eof
	if (c mod row_num)=1 then
	links=links&"<tr>"
	end if
    links=links&"<td class=tablebody1><a href='"&rs("url")&"' title="&rs("boardname")&"&#13;"&rs("readme")&">"&rs("boardname")&"</a></td>"
    if (c mod row_num)=0 then
	links=links&"</tr>"
	end if
	c=c+1
	rs.MoveNext()
	loop
	links=links&"</tr>"
	links=links&"</table>"
rs.close:set rs=nothing
Getlinks=links
end function
%>