<!--#include file="conn.asp"-->
<!--#include file="inc/const.asp"-->
<!--#include file="inc/dv_clsother.asp"-->
<!--#include file="inc/dv_ubbcode.asp"-->
<!--#include file="inc/ubblist.asp"-->
<%
Dim TemplateStr,dhy_rs,dhy_sql,dhy_name,crs,rs,drs,sql,usID,i,yn,filec
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 not Dvbbs.Founduser then
   errs("您还没有<a href=login.asp>登录论坛</a>，不能管理个人主页。如果您还没有<a href=reg.asp>注册</a>，请先<a href=reg.asp>注册</a>！")
else
   usID=dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userid").text
end if
set dhy_rs =Dvbbs.Execute("select site_name,yn from dhy_index where userID="&usID)
if dhy_rs.eof or dhy_rs.bof then
   dhy_rs.close:set dhy_rs=nothing
   errs("你还没有申请自己的个人主页！<a href=dhy_reg.asp><font color=red>我要申请</font></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_rs.close:set dhy_rs=nothing
Dvbbs.Stats="<a href=dhy_index.asp?usID="&usid&">"&dhy_name&"</a> → 管理我的主页"
Dvbbs.Nav()
If Dvbbs.BoardID=0 Then
	Dvbbs.Head_var 2,0,"",""
Else
	Dvbbs.Head_var 1,Dvbbs.Board_Data(4,0),"",""
End If

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

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

Response.Write "<table cellpadding=3 cellspacing=1 align=center class=tableborder1 style=word-break:break-all>"
Response.Write "<tr>"
Response.Write "<th height=25 id=tabletitlelink><a href=?action=main>主页基本信息</a></th>"
Response.Write "<th id=tabletitlelink><a href=?action=msm>资料修改</a></th>"
Response.Write "<th id=tabletitlelink><a href=?action=bulletin>公告管理</a></th>"
Response.Write "<th id=tabletitlelink><a href=?action=fileclass>文章分类</a></th>"
Response.Write "<th id=tabletitlelink><a href=?action=add>添加文章</a></th>"
Response.Write "<th id=tabletitlelink><a href=?action=links>友情连接</a></th>"
Response.Write "<th id=tabletitlelink><a href=?action=off><font color=red>注消主页</font></a></th>"
Response.Write "<th id=tabletitlelink><a href=dhy_index.asp?usID="&usid&">退出管理</a></th>"
Response.Write "</tr>"
Response.Write "</table>"

function gl(str,str1)
If str="" or Instr(str,"%")>0 or Instr(str,"?")>0 or Instr(str,"&")>0 or Instr(str,";")>0 or Instr(str,"'")>0 or Instr(str,"")>0 or Instr(str,"$")>0 Then
   errs(str1&" 含有非法字符或为空！")
end if
end function

if request("action")="msm" then
   call msm()
elseif request("action")="bulletin" then
   call bulletin()
elseif request("action")="fileclass" then
   call fileclass()
elseif request("action")="add" then
   call add()
elseif request("action")="links" then
   call links()
elseif request("action")="off" then
   call off()
elseif request("action")="admin_file" then
   call admin_file()
else
   call main()
end if
Dvbbs.ActiveOnline()
Dvbbs.Footer()

public sub main()
set rs = Server.CreateObject("ADODB.Recordset")
sql="select site_name,index_sm,new_list_yn,company,new_list_num,click_list_yn,click_list_num,file_list_num,file_no_num from dhy_index where userID="&usID
rs.open sql,conn,1,3
Response.Write "<table cellpadding=4 cellspacing=1 align=center class=tableborder1 style=word-break:break-all>"
response.write "<form method=POST name=form>"
   response.write "<tr>"
   response.write "<td class=tablebody1 width=40% ><b>个人主页名称</b><br>长度限制为2－15字节</td>"
   response.write "<td class=tablebody1><input type=text name=site_name value='"&rs("site_name")&"' maxlength=15 size=30></td>"
   response.write "</tr>"
   response.write "<tr>"
   response.write "<td class=tablebody1 width=40% ><b>主页简介</b><br>显示于主页推荐中，支持HTML语法</td>"
   response.write "<td class=tablebody1><textarea name=index_sm rows=5 cols=65>"&rs("index_sm")&"</textarea>"
   response.write "<img src=images/manage/plus.gif onclick=document.form.index_sm.rows+=4 alt=放大>"
   response.write "<img src=images/manage/minus.gif onclick='if(document.form.index_sm.rows>=4)document.form.index_sm.rows-=4;else return false' alt=缩小>"
   response.write "</td></tr>"
   response.write "<tr>"
   response.write "<td class=tablebody1 width=40% ><b>首页新文章调用</b><br>处于打开状态设置调用数量为有效</td>"
   response.write "<td class=tablebody1>"
   %>
   <label><input type="radio" name="new_list_yn" value="1" <%If (CStr("1") = CStr(rs("new_list_yn"))) Then Response.Write("checked") : Response.Write("")%>>打开</label>
   <label><input type="radio" name="new_list_yn" value="0" <%If (CStr("0") = CStr(rs("new_list_yn"))) Then Response.Write("checked") : Response.Write("")%>>关闭</label>
   <%
   response.write "　调用文章数量 <input type=text name=new_list_num value='"&rs("new_list_num")&"' maxlength=2 size=1> 篇</td>"
   response.write "</tr>"
   response.write "<tr>"
   response.write "<td class=tablebody1 width=40% ><b>首页人气文章调用</b><br>处于打开状态设置调用数量为有效</td>"
   response.write "<td class=tablebody1>"
   %>
   <label><input type="radio" name="click_list_yn" value="1" <%If (CStr("1") = CStr(rs("click_list_yn"))) Then Response.Write("checked") : Response.Write("")%>>打开</label>
   <label><input type="radio" name="click_list_yn" value="0" <%If (CStr("0") = CStr(rs("click_list_yn"))) Then Response.Write("checked") : Response.Write("")%>>关闭</label>
   <%
   response.write "　调用文章数量 <input type=text name=click_list_num value='"&rs("click_list_num")&"' maxlength=2 size=1> 篇</td>"
   response.write "</tr>"
   response.write "<tr>"
   response.write "<td class=tablebody1 width=40% ><b>首页列表数量</b><br>每个分类在首页所调用的文章数量</td>"
   response.write "<td class=tablebody1><input type=text name=file_list_num value='"&rs("file_list_num")&"' maxlength=2 size=1> 篇</td>"
   response.write "</tr>"
   response.write "<tr>"
   response.write "<td class=tablebody1 width=40% ><b>文章分类列表数量</b><br>每个分类所调用的文章数量</td>"
   response.write "<td class=tablebody1><input type=text name=file_no_num value='"&rs("file_no_num")&"' maxlength=2 size=1> 篇</td>"
   response.write "</tr>"
   response.write "<td class=tablebody1 width=40% ><b>文章版权信息</b><br>长度不大于250字节</td>"
   response.write "<td class=tablebody1><input type=text name=company value='"&rs("company")&"' maxlength=250 size=40></td>"
   response.write "</tr>"
   response.write "<tr>"
   response.write "<td class=tablebody2 colspan=2><center><input type=submit name=submit value=提交>　　<input type=button value=返回 onclick='javascript:history.go(-1);'></td>"
   response.write "</tr>"
response.write "</form></table>"
if request.form("submit")<>"" then
response.write gl(request.form("site_name"),"<b>个人主页名称</b>")
response.write gl(request.form("index_sm"),"<b>主页简介</b>")
response.write gl(request.form("new_list_num"),"<b>首页新文章调用数量</b>")
response.write gl(request.form("click_list_num"),"<b>首页人气文章调用数量</b>")
response.write gl(request.form("file_list_num"),"<b>首页列表数量</b>")
response.write gl(request.form("file_no_num"),"<b>文章分类列表</b>")
response.write gl(request.form("company"),"<b>文章版权信息</b>")
   rs("site_name")=request.form("site_name")
   rs("index_sm")=request.form("index_sm")
   rs("new_list_yn")=request.form("new_list_yn")
   rs("new_list_num")=request.form("new_list_num")
   rs("click_list_yn")=request.form("click_list_yn")
   rs("new_list_num")=request.form("new_list_num")
   rs("file_list_num")=request.form("file_list_num")
   rs("file_no_num")=request.form("file_no_num")
   rs("company")=request.form("company")
   rs.update
rs.close:set rs=nothing
response.write "<script languge='javascript'>alert('操作已成功！');location.href('dhy_admin.asp?action=main');</script>"
end if
rs.close:set rs=nothing
end sub

public sub msm()
set rs = Server.CreateObject("ADODB.Recordset")
sql="select zs_name,zs_tel,zs_code,zs_add,E_mail,userphoto,width,height,user_sm from dhy_index where userID="&usID
rs.open sql,conn,1,3
Response.Write "<table cellpadding=4 cellspacing=1 align=center class=tableborder1 style=word-break:break-all>"
response.write "<form method=POST name=form>"
   response.write "<tr>"
   response.write "<td class=tablebody1 width=40% ><b>姓　　名</b><br>长度限制为2－15字节(只有管理员可见)</td>"
   response.write "<td class=tablebody1><input type=text name=zs_name value='"&rs("zs_name")&"' maxlength=15 size=30></td>"
   response.write "</tr>"
   response.write "<tr>"
   response.write "<td class=tablebody1 width=40% ><b>电子信箱</b><br>你的电子信箱</td>"
   response.write "<td class=tablebody1><input type=text name=E_mail value='"&rs("E_mail")&"' maxlength=30 size=30></td>"
   response.write "</tr>"
   response.write "<tr>"
   response.write "<td class=tablebody1 width=40% ><b>电　　话</b><br>你的联系电话，便于管理员工作。(只有管理员可见)</td>"
   response.write "<td class=tablebody1><input type=text name=zs_tel value='"&rs("zs_tel")&"' maxlength=30 size=30></td>"
   response.write "</tr>"
   response.write "<tr>"
   response.write "<td class=tablebody1 width=40% ><b>邮　　编</b><br>你的连接地址所在地的邮政编码。(只有管理员可见)</td>"
   response.write "<td class=tablebody1><input type=text name=zs_code value='"&rs("zs_code")&"' maxlength=6 size=6></td>"
   response.write "</tr>"
   response.write "<tr>"
   response.write "<td class=tablebody1 width=40% ><b>联系地址</b><br>你的真实地址，便于管理员工作。(只有管理员可见)</td>"
   response.write "<td class=tablebody1><input type=text name=zs_add value='"&rs("zs_add")&"' maxlength=200 size=50></td>"
   response.write "</tr>"
   response.write "<tr>"
   response.write "<td class=tablebody1 width=40% ><b>你的照片地址</b><br>显示于你主页的作者简介栏,如不须要请留言空</td>"
   response.write "<td class=tablebody1><input type=text name=userphoto value='"&rs("userphoto")&"' maxlength=200 size=50>"
   response.write " 宽 <input type=text name=width value='"&rs("width")&"' maxlength=3 size=1>"
   response.write " 高 <input type=text name=height value='"&rs("height")&"' maxlength=3 size=1>"
   response.write "</td>"
   response.write "</tr>"
   response.write "<tr>"
   response.write "<td class=tablebody1 width=40% ><b>个人简介</b><br>支持HTML，显示于主页首页</td>"
   response.write "<td class=tablebody1><textarea name=user_sm rows=5 cols=65>"&rs("user_sm")&"</textarea>"
   response.write "<img src=images/manage/plus.gif onclick=document.form.user_sm.rows+=4 alt=放大>"
   response.write "<img src=images/manage/minus.gif onclick='if(document.form.user_sm.rows>=4)document.form.user_sm.rows-=4;else return false' alt=缩小>"
   response.write "</td></tr>"
   response.write "<tr>"
   response.write "<td class=tablebody2 colspan=2><center><input type=submit name=submit value=提交>　　<input type=button value=返回 onclick='javascript:history.go(-1);'></td>"
   response.write "</tr>"
response.write "</form></table>"
if request.form("submit")<>"" then
response.write gl(request.form("zs_name"),"<b>你的真实姓名</b>")
response.write gl(request.form("E_mail"),"<b>电子信箱</b>")
response.write gl(request.form("user_sm"),"<b>个人简介</b>")
response.write gl(request.form("width"),"<b>照片宽度值</b>")
response.write gl(request.form("height"),"<b>照片高度值</b>")
   rs("zs_name")=request.form("zs_name")
   rs("E_mail")=request.form("E_mail")
   rs("zs_tel")=request.form("zs_tel")
   rs("zs_code")=request.form("zs_code")
   rs("zs_add")=request.form("zs_add")
   rs("userphoto")=request.form("userphoto")
   rs("width")=request.form("width")
   rs("height")=request.form("height")
   rs("user_sm")=request.form("user_sm")
   rs.update
rs.close:set rs=nothing
Application.Lock
Application("writes")=""
application.unlock
response.write "<script languge='javascript'>alert('操作已成功！');location.href('dhy_admin.asp?action=msm');</script>"
end if
rs.close:set rs=nothing
end sub

public sub bulletin()
set rs = Server.CreateObject("ADODB.Recordset")
sql="select index_gg from dhy_index where userID="&usID
rs.open sql,conn,1,3
Response.Write "<table cellpadding=4 cellspacing=1 align=center class=tableborder1 style=word-break:break-all>"
response.write "<form method=POST name=form>"
   response.write "<tr>"
   response.write "<td class=tablebody1 width=40% ><b>主页公告</b><br>支持HTML，显示于主页首页</td>"
   response.write "<td class=tablebody1><textarea name=index_gg rows=5 cols=65>"&rs("index_gg")&"</textarea>"
   response.write "<img src=images/manage/plus.gif onclick=document.form.index_gg.rows+=4 alt=放大>"
   response.write "<img src=images/manage/minus.gif onclick='if(document.form.index_gg.rows>=4)document.form.index_gg.rows-=4;else return false' alt=缩小>"
   response.write "</td></tr>"
   response.write "<tr>"
   response.write "<td class=tablebody2 colspan=2><center><input type=submit name=submit value=提交>　　<input type=button value=返回 onclick='javascript:history.go(-1);'></td>"
   response.write "</tr>"
response.write "</form></table>"
if request.form("submit")<>"" then
response.write gl(request.form("index_gg"),"<b>主页公告</b>")
   rs("index_gg")=request.form("index_gg")
   rs.update
rs.close:set rs=nothing
Application.Lock
Application("gg")=""
application.unlock
response.write "<script languge='javascript'>alert('操作已成功！');location.href('dhy_admin.asp?action=bulletin');</script>"
end if
rs.close:set rs=nothing
end sub

public sub fileclass()
if request("del")="" then
set rs = Server.CreateObject("ADODB.Recordset")
sql="select id,userid,class_name,filenum,yn from [dhy_class] where userID="&usID
rs.open sql,conn,1,3
Response.Write "<table cellpadding=4 cellspacing=1 align=center class=tableborder1 style=word-break:break-all>"
   i=1
   do while not rs.eof
      response.write "<form method=POST name=form1 action=?action=fileclass&fid="&rs("id")&">"
      response.write "<tr>"
      response.write "<td class=tablebody1 width=40% ><b>文章分类"&i&"</b><br>支持HTML，长度限制为2－15字节<br>"
	  if rs("filenum")>0 then:response.write "该文章分类下有 <font color=red>"&rs("filenum")&"</font> 篇文章":else:response.write "该文章分类下没有任何文章"
	  response.write "</td>"
      response.write "<td class=tablebody1><input type=text name=class_name value='"&rs("class_name")&"' maxlength=30 size=30>"
      %>
    　<input type="checkbox" name="yn" value="1" <%If rs("yn")=1 Then Response.Write("checked") else response.write "" end if%>>
      <%
	  response.write "　<input type=submit name=submit value='修改'>　"
	  response.write "<input type=submit name=submit value='删除'>"
      response.write "</td></form></tr>"
   i=i+1
   rs.movenext()
   loop
   response.write "<form method=POST name=form>"
   response.write "<tr>"
   response.write "<td class=tablebody1 width=40% ><b>添加新的文章分类</b><br>支持HTML，长度限制为2－15字节</td>"
   response.write "<td class=tablebody1><input type=text name=class_name maxlength=30 size=30>"
   response.write "　 <input type=checkbox name=yn value=1 checked>"
   response.write "　 <input type=submit name=submit value='添加新的分类'>"
   response.write "</td></form></tr>"
   response.write "<tr>"
   response.write "<td class=tablebody2 colspan=2><li>注意：删除分类要确保该分类下的文章为空，否则将删除该分类下的所有文章。</td>"
   response.write "</tr>"
response.write "</table>"
if request.form("submit")="添加新的分类" then
   response.write gl(request.form("class_name"),"<b>文章分类</b>")
   if request.form("yn")<>"" then yn=1:else:yn=0:end if
   Dvbbs.Execute("insert into [dhy_class] (userid,class_name,filenum,yn) Values ('"&usID&"','"&request.form("class_name")&"',0,'"&yn&"')")
   rs.close:set rs=nothing
   response.write "<script languge='javascript'>alert('操作已成功！');location.href('dhy_admin.asp?action=fileclass');</script>"
elseif request.form("submit")="修改" then
   response.write gl(request.form("class_name"),"<b>文章分类</b>")
   if request.form("yn")<>"" then yn=1:else:yn=0:end if
   Dvbbs.Execute("update [dhy_class] set class_name='"&request.form("class_name")&"',yn="&yn&" where id="&request("fid"))
   rs.close:set rs=nothing
   response.write "<script languge='javascript'>alert('操作已成功！');location.href('dhy_admin.asp?action=fileclass');</script>"
elseif request.form("submit")="删除" then
   response.redirect "?action=fileclass&del="&request("fid")
end if
rs.close:set rs=nothing
else
if not isnumeric(request("del")) then errs("请勿从外部提交数据！")
set rs = Server.CreateObject("ADODB.Recordset")
sql="select id,userid,class_name,filenum,yn from dhy_class where userID="&usID&" and id="&request("del")
rs.open sql,conn,1,3
  if rs.eof then errs("请勿从外部提交数据！")
  if request.form("submit")<>"" then
  Dvbbs.Execute("update [dhy_index] set file_num=file_num-"&rs("filenum")&" where userid="&usID)
  Dvbbs.Execute("delete from [dhy_file] where FileClass="&request("del"))
  Dvbbs.Execute("delete from [dhy_class] where id="&request("del"))
  response.write "<script languge='javascript'>alert('操作已成功！');location.href('dhy_admin.asp?action=fileclass');</script>"
  end if
  Response.Write "<table cellpadding=4 cellspacing=1 align=center class=tableborder1 style=word-break:break-all>"
  response.write "<tr>"
  response.write "<td class=tablebody1>"
  response.write "<li>你要删除的文章分类：<font color=red><b>"&rs("class_name")&"</b></font><br>"
  if rs("filenum")>0 then
     response.write "<li>该文章分类下面目前含有文章：<font color=red><b>"&rs("filenum")&"</b></font> 篇，你确定要删除吗？删除后将同时删除该文章分类下的所有文章,该删除不能回恢，请谨慎操作!"
  else
     response.write "<li>该文章分类下面目前含有文章：<font color=red><b>"&rs("filenum")&"</b></font> 篇，你你可以安全删除该分类"
  end if
  response.write "</td>"
  response.write "</tr>"
  response.write "<form method=POST name=form>"
  response.write "<tr>"
  response.write "<td class=tablebody2><center>"
  response.write "<input type=submit name=submit value='删除'>　"
  response.write "<input type=button value=返回 onclick='javascript:history.go(-1);'>"
  response.write "</td>"
  response.write "</tr></form>"
  response.write "</table>"
rs.close:set rs=nothing
end if
end sub

public sub add()
set rs=Dvbbs.Execute("select id from [dhy_class] where userid="&usID)
if rs.eof then
  Response.Write "<table cellpadding=4 cellspacing=1 align=center class=tableborder1 style=word-break:break-all>"
  response.write "<tr>"
  response.write "<td class=tablebody1 height=30>"
  response.write "<li>你还没有添加任何文章分类，暂时不能添加文章！"
  response.write "</td>"
  response.write "</tr>"
  response.write "<tr>"
  response.write "<td class=tablebody2 height=25><center>"
  response.write "<a href=?action=fileclass>添加文章分类</a>"
  response.write "</td>"
  response.write "</tr>"
  response.write "</table>"
else
rs.close:set rs=nothing
dim index,page,pages,nowpage
Page=request("page")
If Page="" Or Not IsNumerIc(Page) or page=0 Then Page=1
Page=Clng(Page)
if request("orders")<>"" then
   response.cookies("orders")=request("orders")
end if
  Response.Write "<table cellpadding=4 cellspacing=1 align=center class=tableborder1 style=word-break:break-all>"
  response.write "<tr>"
  response.write "<td class=tablebody2 colspan=7>"
  response.write "<form method=POST action=?action=add>"
  response.write "社区我的文章搜索：<select name=orders onchange='javascript:submit()'>"
  set rs=Dvbbs.Execute("select boardid,boardType from [Dv_board] where parentID=0 order by RootID")
  do while not rs.eof
  response.write "<option value="&rs("boardid")&">╋"&rs("boardtype")&"</option>"
     set dhy_rs=Dvbbs.Execute("select boardid,boardType from [Dv_board] where parentID="&rs("boardID")&" order by orders")
	 do while not dhy_rs.eof
	 %>
     <option value="<%=dhy_rs("boardid")%>" <%if (cstr(request.cookies("orders"))=cstr(dhy_rs("boardid"))) then  response.write("selected") end if%>>　├<%=dhy_rs("boardtype")%></option>
	 <%
	 dhy_rs.movenext()
	 loop
	 dhy_rs.close:set dhy_rs=nothing
  rs.movenext()
  loop
  rs.close:set rs=nothing
  response.write "</select>"
  response.write "&nbsp;关键字搜索：<input type=text size=30 name=keyword> <input type=submit name=Submit value=搜索>　"
response.write "</td></form></tr>"
response.write "<tr>"
response.write "<td class=tablebody2 width=5% ><center><b>状态</b></td>"
response.write "<td class=tablebody2 width=50% ><center><b>文章标题</b></td>"
response.write "<td class=tablebody2 width=5% ><center><b>回复</b></td>"
response.write "<td class=tablebody2 width=5% ><center><b>人气</b></td>"
response.write "<td class=tablebody2 width=20% ><center><b>发表时间</b></td>"
response.write "<td class=tablebody2 width=10% ><center><b>文章分类</b></td>"
response.write "<td class=tablebody2 width=5% ><center><b>操作</b></td>"
response.write "</tr>"
Set rs = Server.CreateObject("ADODB.Recordset")
if request("keyword")<>"" then
   sql= "select topicid,boardid,title,child,hits,DateAndTime from [Dv_Topic] where postuserid="&usid&" and title like '%"&request("keyword")&"%' order by DateAndTime desc"
elseif request("orders")<>"" then
   sql= "select topicid,boardid,title,child,hits,DateAndTime from [Dv_Topic] where postuserid="&usid&" and BoardID="&request("orders")&" order by DateAndTime desc"
else
   sql= "select top 20 topicid,boardid,title,child,hits,DateAndTime from [Dv_Topic] where postuserid="&cint(usid)&" order by DateAndTime desc"
end if
rs.open sql,conn,1,3
if rs.eof then
   response.write "<tr>"
   response.write "<td class=tablebody1 colspan=7>"
   response.write "<li>没有找到任何文章，请偿试输入较短的关键字或其它社区分类重新搜索！"
   response.write "</td>"
   response.write "</tr>"
else
   index = 0
   rs.pagesize=20
   rs.movefirst
   nowpage=page
   rs.absolutepage=nowpage
   pages=rs.PageCount
   do while not rs.eof
   response.write "<tr>"
   set crs=Dvbbs.Execute("select id from [dhy_file] where fileid="&rs("TopicID"))
   if not crs.eof then
      response.write "<td class=tablebody2><center><img src=Skins/Default/css/baio/d9.gif alt=该文章已经添加到我的主页></td>"
   else
      response.write "<td class=tablebody2><center><img src=Skins/Default/css/baio/a8.gif alt=该文章还未添加到我的主页></td>"
   end if
   crs.close:set crs=nothing
   if rs("child")>0 then
      response.write "<td class=tablebody1><img src=Skins/Default/plus.gif><a href=dispbbs.asp?boardID="&rs("boardid")&"&ID="&rs("topicid")&" target=_blank title=查看原贴>"&left(rs("title"),80)&"</a></td>"
   else
      response.write "<td class=tablebody1><img src=Skins/Default/nofollow.gif><a href=dispbbs.asp?boardID="&rs("boardid")&"&ID="&rs("topicid")&" target=_blank title=查看原贴>"&left(rs("title"),80)&"</a></td>"
   end if
   response.write "<td class=tablebody2><center>"&rs("child")&"</td>"
   response.write "<td class=tablebody1><center>"&rs("hits")&"</td>"
   response.write "<td class=tablebody2><center>"&rs("DateAndTime")&"</td>"
   response.write "<td class=tablebody1><center>"
   set crs=Dvbbs.Execute("select id,FileClass from [dhy_file] where fileid="&rs("TopicID"))
   if crs.eof then
      response.write "未加入"
      crs.close:set crs=nothing
   else
      set drs=Dvbbs.Execute("select class_name from [dhy_class] where userid="&usID&" and id="&crs("FileClass"))
      response.write "<font color=red>"&drs("class_name")&"</font>"
      drs.close:set drs=nothing
      crs.close:set crs=nothing
   end if
   response.write "</td>"
   response.write "<td class=tablebody2><center><a href=?action=admin_file&fid="&rs("TopicID")&"><b>操作</b></a></td>"
   response.write "</tr>"
   index=index+1
   if index=rs.pagesize then exit do
   rs.movenext()
   loop
end if
response.write "</table>"
Response.Write "<table cellpadding=4 cellspacing=0 align=center class=tableborder1 style=word-break:break-all>"
response.write "<tr>"
response.write "<td class=tablebody2 width=50% >"
response.write "页次：<b>"&nowpage&"</b> / <b>"&pages&"</b> 每页<b>"&rs.pagesize&"</b>条记录 共有<b>"&rs.recordcount&"</b>个主页"
response.write "</td><td class=tablebody2 align=right>"
if pages="" then pages=1
if nowpage="" then nowpage=1
response.write "分页："
   dim xpage,xten,tos
   if nowpage mod 10=0 then
      xpage=nowpage-1
   else
      xpage=nowpage
   end if
   xten=int(xpage/10)*10
   if nowpage=1 then
      response.write "<font face=dhydings color=red>9</font>"
   else
      if request("keyword")<>"" then
         response.write "<a href=?action=add&keyword="&request("keyword")&"&page=1 title=首页><font face=dhydings>9</font></a>"
      elseif request("orders")<>"" then
         response.write "<a href=?action=add&orders="&request("orders")&"&page=1 title=首页><font face=dhydings>9</font></a>"
	  else
         response.write "<a href=?action=add&page=1 title=首页><font face=dhydings>9</font></a>"
	  end if
   end if
   if nowpage>10 then
      if request("keyword")<>"" then
         response.write "<a href=?action=add&keyword="&request("keyword")&"&page="&xten&" title=前十页><font face=dhydings>7</font></a>"
      elseif request("orders")<>"" then
         response.write "<a href=?action=add&orders="&request("orders")&"&page="&xten&" title=前十页><font face=dhydings>7</font></a>"
	  else
         response.write "<a href=?action=add&page="&xten&" title=前十页><font face=dhydings>7</font></a>"
	  end if
   end if
   if pages-xten>11 then
      tos=xten+10
   else
      tos=pages
   end if
   for i=xten+1 to tos
       if i=nowpage then
          response.write " <font color=red><b>"&i&"</b></a> "
	   else
          if request("keyword")<>"" then
	         response.write " <a href=?action=add&keyword="&request("keyword")&"&page="&i&"><b>"&i&"</b></a> "
          elseif request("orders")<>"" then
             response.write " <a href=?action=add&orders="&request("orders")&"&page="&i&"><b>"&i&"</b></a> "
	      else
	         response.write " <a href=?action=add&page="&i&"><b>"&i&"</b></a> "
	      end if
	   end if
   next
   if pages-xten>10 then
      if request("keyword")<>"" then
         response.write "<a href=?action=add&keyword="&request("keyword")&"&page="&xten+11&" title=后十页><font face=dhydings>8</font></a>"
      elseif request("orders")<>"" then
         response.write "<a href=?action=add&orders="&request("orders")&"&page="&xten+11&" title=后十页><font face=dhydings>8</font></a>"
	  else
         response.write "<a href=?action=add&page="&xten+11&" title=后十页><font face=dhydings>8</font></a>"
	  end if
   end if
   if pages=nowpage or pages=1 then
      response.write "<font face=dhydings color=red>:</font>"
   else
      if request("keyword")<>"" then
         response.write "<a href=?action=add&keyword="&request("keyword")&"&page="&pages&" title=尾页><font face=dhydings>:</font></a>"
      elseif request("orders")<>"" then
         response.write "<a href=?action=add&orders="&request("orders")&"&page="&pages&" title=尾页><font face=dhydings>:</font></a>"
	  else
         response.write "<a href=?action=add&page="&pages&" title=尾页><font face=dhydings>:</font></a>"
	  end if
   end if
response.write "</td></tr></table>"
rs.close:set rs=nothing
end if
end sub

public sub admin_file()
if not isnumeric(request("fid")) then  errs("请勿从外部提交数据！")
set rs=Dvbbs.Execute("select topicid,title,boardid,postusername,postuserid,child,hits,PostTable,DateAndTime from [Dv_Topic] where postuserID="&usID&" and topicid="&request("fid"))
if rs.eof then  errs("没有找到任何文章！<li>该文章的作者不是你，你只能添加你自己的文章！<li>请勿从外部提交数据！")
Response.Write "<table cellpadding=4 cellspacing=1 align=center class=tableborder1 style=word-break:break-all>"
response.write "<form method=POST name=form>"
   response.write "<tr>"
   response.write "<td class=tablebody1 width=40% ><b>文章标题</b></td>"
   response.write "<td class=tablebody1><a href=dispbbs.asp?boardID="&rs("boardid")&"&ID="&rs("topicid")&" target=_blank title=查看原贴>"&rs("title")&"</a></td></tr>"
   response.write "<tr>"
   response.write "<td class=tablebody1 width=40% ><b>回复次数</b></td>"
   response.write "<td class=tablebody1>"&rs("child")&" 篇</td></tr>"
   response.write "<tr>"
   response.write "<td class=tablebody1 width=40% ><b>访问次数</b></td>"
   response.write "<td class=tablebody1>"&rs("hits")&" 人次</td></tr>"
   response.write "<tr>"
   response.write "<td class=tablebody1 width=40% ><b>发表时间</b></td>"
   response.write "<td class=tablebody1>"&rs("DateAndTime")&"</td></tr>"
   response.write "<tr>"
   response.write "<td class=tablebody1 width=40% ><b>选择分类</b><br>选择该文章所在你主页的分类</td>"
   response.write "<td class=tablebody1>"
   response.write "<select name=fileclass>"
   set crs=Dvbbs.Execute("select id,userid,class_name from [dhy_class] where userID="&usID&" order by ID")
   do while not crs.eof
   set drs=Dvbbs.Execute("select id,FileClass from [dhy_file] where fileid="&rs("TopicID"))
   if not drs.eof then
   %>
   <option value="<%=crs("id")%>" <%if (cstr(drs("FileClass"))=cstr(crs("id"))) then response.write("selected") end if%>><%=crs("class_name")%></option>
   <%
   drs.close:set drs=nothing
   else
   response.write "<option value='"&crs("id")&"'>"&crs("class_name")&"</option>"
   end if
   crs.movenext()
   loop
   crs.close:set crs=nothing
   response.write "</select>"
   response.write "</td></tr>"
   response.write "<tr>"
   response.write "<td class=tablebody2 colspan=2><center>"
   set drs=Dvbbs.Execute("select id,FileClass from [dhy_file] where fileid="&rs("TopicID"))
   if not drs.eof then
   dim fc
   fc=drs("FileClass")
      response.write "<input type=submit name=submit value=更新>　　"
      response.write "<input type=submit name=submit value=删除>　　"
   else
      response.write "<input type=submit name=submit value=提交>　　"
   end if
   drs.close:set drs=nothing
   response.write "<input type=button value=返回 onclick='javascript:history.go(-1);'></td>"
   response.write "<input type=hidden name=historys value="&Request.ServerVariables("HTTP_REFERER")&">"
   response.write "</tr>"
response.write "</form></table>"
if request.form("submit")="提交" then
   Dvbbs.Execute("update [dhy_class] set filenum=filenum+1 where id="&request.form("fileclass"))
   Dvbbs.Execute("insert into [dhy_file] (FileID,FileClass) Values ('"&rs("TopicID")&"','"&request.form("fileclass")&"')")
   Dvbbs.Execute("update [dhy_index] set file_num=file_num+1 where userid="&usID)
   rs.close:set rs=nothing
   response.write "<script>alert('操作已成功');location.href('"&request("historys")&"');</script>"
elseif request.form("submit")="更新" then
   Dvbbs.Execute("update [dhy_class] set filenum=filenum-1 where id="&fc)
   Dvbbs.Execute("update [dhy_class] set filenum=filenum+1 where id="&request.form("fileclass"))
   Dvbbs.Execute("update [dhy_file] set FileClass='"&request.form("fileclass")&"' where FileID="&request("fid"))
   response.write "<script>alert('操作已成功');location.href('"&request("historys")&"');</script>"
elseif request.form("submit")="删除" then
   Dvbbs.Execute("update [dhy_class] set filenum=filenum-1 where id="&request.form("fileclass"))
   Dvbbs.Execute("update [dhy_index] set file_num=file_num-1 where userid="&usID)
   Dvbbs.Execute("delete from [dhy_file] where fileid="&request("fid"))
   rs.close:set rs=nothing
   response.write "<script>alert('操作已成功');location.href('"&request("historys")&"');</script>"
end if
rs.close:set rs=nothing
end sub

public sub links()
dim edit,del
edit=request("edit")
del=request("del")
if not isnumeric(edit) then errs("请勿从外部提交数据！")
if not isnumeric(del) then errs("请勿从外部提交数据！")
if del<>"" then
set rs=Dvbbs.Execute("select id from [dhy_link] where userid="&usID&" and id="&del)
if rs.eof then rs.close:set rs=nothing:errs("请勿从外部提交数据！")
Dvbbs.Execute("delete from [dhy_link] where id="&del)
response.write "<script languge='javascript'>alert('操作已成功！');location.href('dhy_admin.asp?action=links');</script>"
end if
set rs = Server.CreateObject("ADODB.Recordset")
if edit<>"" then
   sql="select id,boardname,readme,url,logo,islogo,userid from [dhy_link] where userid="&usid&" and id="&edit
else
   sql="select id,boardname,readme,url,logo,islogo,userid from [dhy_link]"
end if
rs.open sql,conn,1,3
if edit<>"" and rs.eof then rs.close:set rs=nothing:response.redirect "?action=links"
if request.form("submit")<>"" then
response.write gl(request.form("boardname"),"<b>网站名称</b>")
response.write gl(request.form("url"),"<b>连接URL</b>")
response.write gl(request.form("readme"),"<b>网站简介</b>")
   if edit="" then
   rs.addnew
   end if
   rs("boardname")=request.form("boardname")
   rs("url")=request.form("url")
   rs("logo")=request.form("logo")
   rs("readme")=request.form("readme")
   rs("islogo")=request.form("islogo")
   rs("userid")=usID
   rs.update
rs.close:set rs=nothing
Application.Lock
Application("links")=""
Application.unlock
response.write "<script languge='javascript'>alert('操作已成功！');location.href('dhy_admin.asp?action=links');</script>"
end if
Response.Write "<table cellpadding=4 cellspacing=1 align=center class=tableborder1 style=word-break:break-all>"
response.write "<form method=POST name=form>"
   response.write "<tr>"
   response.write "<td class=tablebody1 width=40% ><b>网站名称</b></td>"
   if edit<>"" then
   response.write "<td class=tablebody1><input type=text name=boardname value='"&rs("boardname")&"' maxlength=15 size=50></td>"
   else
   response.write "<td class=tablebody1><input type=text name=boardname maxlength=15 size=50></td>"
   end if
   response.write "</tr>"
   response.write "<tr>"
   response.write "<td class=tablebody1 width=40% ><b>连接URL</b></td>"
   if edit<>"" then
   response.write "<td class=tablebody1><input type=text name=url value='"&rs("url")&"' maxlength=100 size=50></td>"
   else
   response.write "<td class=tablebody1><input type=text name=url maxlength=100 size=50></td>"
   end if
   response.write "</tr>"
   response.write "<tr>"
   response.write "<td class=tablebody1 width=40% ><b>连接LOGO地址</b></td>"
   if edit<>"" then
   response.write "<td class=tablebody1><input type=text name=logo value='"&rs("logo")&"' maxlength=100 size=50></td>"
   else
   response.write "<td class=tablebody1><input type=text name=logo maxlength=100 size=50></td>"
   end if
   response.write "</tr>"
   response.write "<tr>"
   response.write "<td class=tablebody1 width=40% ><b>网站简介</b></td>"
   if edit<>"" then
   response.write "<td class=tablebody1><input type=text name=readme value='"&rs("readme")&"' maxlength=249 size=50></td>"
   else
   response.write "<td class=tablebody1><input type=text name=readme maxlength=249 size=50></td>"
   end if
   response.write "</tr>"
   response.write "<tr>"
   response.write "<td class=tablebody1 width=40% ><b>在首页是文字连接还是LOGO连接</b></td>"
   response.write "<td class=tablebody1>"
   if edit<>"" then
   %>
   <label><input type="radio" name="islogo" value="0" <%if (cstr("0") = cstr(rs("islogo"))) then response.write("checked"):response.write("")%>>文字连接</label>
   <label><input type="radio" name="islogo" value="1"  <%if (cstr("1") = cstr(rs("islogo"))) then response.write("checked"):response.write("")%>>LOGO连接</label>
   <%
   else
   response.write "<label><input type=radio name=islogo value=0 checked>文字连接</label>"
   response.write "<label><input type=radio name=islogo value=1>LOGO连接</label>"
   end if
   response.write "</td>"
   response.write "</tr>"
   response.write "<tr>"
   if edit<>"" then
   response.write "<td class=tablebody2 colspan=2><center><input type=submit name=submit value=修改></td>"
   else
   response.write "<td class=tablebody2 colspan=2><center><input type=submit name=submit value=添加></td>"
   end if
   response.write "</tr>"
response.write "</form></table>"
rs.close:set rs=nothing

set rs = Dvbbs.Execute("select id,boardname,readme,url,logo,islogo from [dhy_link] where userID="&usID)
if not rs.eof then
Response.Write "<br><table cellpadding=3 cellspacing=1 align=center class=tableborder1 style=word-break:break-all>"
Response.Write "<tr>"
Response.Write "<th height=25 id=tabletitlelink>已添加的友情连接</th>"
Response.Write "</tr>"
Response.Write "</table>"
Response.Write "<table cellpadding=4 cellspacing=1 align=center class=tableborder1 style=word-break:break-all>"
response.write "<tr>"
response.write "<td class=tablebody2 width=15% ><center><b>网站名称</b></td>"
response.write "<td class=tablebody2 width=15% ><center><b>连接方式</b></td>"
response.write "<td class=tablebody2 width=55% ><center><b>网站简介</b></td>"
response.write "<td class=tablebody2 width=15% ><center><b>操作</b></td>"
response.write "</tr>"
do while not rs.eof
response.write "<tr>"
response.write "<td class=tablebody1><a href="&rs("url")&" target=_blank>"&rs("boardname")&"</a></td>"
if rs("islogo")=1 then
   response.write "<td class=tablebody1><center><img src="&rs("logo")&" width=88 height=31 border=0 alt="&rs("readme")&"></td>"
else
   response.write "<td class=tablebody1><center>文字连接</td>"
end if
response.write "<td class=tablebody1>"&left(rs("readme"),40)&"</td>"
response.write "<td class=tablebody1><center><a href=?action=links&edit="&rs("id")&">修改</a> <a href=?action=links&del="&rs("id")&">删除</a></td>"
response.write "</tr>"
rs.movenext()
loop
response.write "</table>"
end if
rs.close:set rs=nothing
end sub

public sub off()
set rs=Dvbbs.Execute("select site_name,file_num,click_num,add_time from [dhy_index] where userid="&usID)
if request.form("submit")<>"" then
   Dvbbs.Execute("update [dhy_index] set yn=2 where userid="&usID)
   response.write "<script languge='javascript'>alert('你的网站已注消成功！');location.href('index.asp');</script>"
end if
  Response.Write "<table cellpadding=4 cellspacing=1 align=center class=tableborder1 style=word-break:break-all>"
  response.write "<form method=POST name=form>"
  response.write "<tr>"
  response.write "<td class=tablebody1 height=30>"
  response.write "<li>你的网站名称："&rs("site_name")
  response.write "<li>网站文章总数："&rs("file_num")&" 篇"
  response.write "<li>网站人气总量："&rs("click_num")&" 人次"
  response.write "<li>建建日期时间："&rs("add_time")
  response.write "<li>你确定要删除你的网站吗？"
  response.write "</td>"
  response.write "</tr>"
  response.write "<tr>"
  response.write "<td class=tablebody2 height=25><center>"
  response.write "<input type=submit name=submit value=我想好了，我决定要注消 onclick=return(confirm('你确定要删除吗？如果后悔还来得及哦!!!'))>　　"
  response.write "<input type=button value=还是不注消了 onclick='javascript:history.go(-1);'>"
  response.write "</td>"
  response.write "</tr>"
  response.write "</form>"
  response.write "</table>"
rs.close:set rs=nothing
end sub
%>