<!-- #include file="Setup.asp" -->


<%

if CookieUserName=empty then error("<li>您还未<a href=Login.asp>登录</a>论坛")

id=int(Request("id"))
url=HTMLEncode(Request("url"))
name=HTMLEncode(Request("name"))
Category=HTMLEncode(Request("Category"))
Description=HTMLEncode(Request("Description"))

top

select case Request("menu")

case "EditUp"
Rs.Open "select * from [BBSXP_Favorites] where UserName='"&CookieUserName&"' and id="&id&"",Conn,1,3
Rs("name")=name
Rs("url")=url
Rs("Category")=Category
Rs("Description")=Description
Rs("UserName")=CookieUserName
Rs.update
Rs.close
Message="<li>编辑成功<li><a href=MyFavorites.asp>返回收藏夹</a><li><a href=Default.asp>返回社区首页</a>"
succeed(""&Message&"<meta http-equiv=refresh content=3;url=MyFavorites.asp>")

case "add"
if name="" then error("<li>名称不能没有填写！")
Rs.Open "select * from [BBSXP_Favorites] where UserName='"&CookieUserName&"' and name='"&name&"' and url='"&url&"'",Conn,1,3
if Rs.eof then Rs.addNew
Rs("name")=name
Rs("url")=url
Rs("Category")=Category
Rs("Description")=Description
Rs("UserName")=CookieUserName
Rs.update
Rs.close
Message="<li>添加成功<li><a href="&Request.ServerVariables("http_referer")&">"&Request.ServerVariables("http_referer")&"</a><li><a href=Default.asp>返回社区首页</a>"
succeed(""&Message&"<meta http-equiv=refresh content=3;url="&Request.ServerVariables("http_referer")&">")


case "Delweb"
Conn.execute("Delete from [BBSXP_Favorites] where UserName='"&CookieUserName&"' and id="&id&"")
Message="<li>删除成功<li><a href="&Request.ServerVariables("http_referer")&">"&Request.ServerVariables("http_referer")&"</a><li><a href=Default.asp>返回社区首页</a>"
succeed(""&Message&"<meta http-equiv=refresh content=3;url="&Request.ServerVariables("http_referer")&">")


case "Del"
Conn.execute("Delete from [BBSXP_Favorites] where UserName='"&CookieUserName&"' and url='"&url&"' and name='"&name&"'")
Message="<li>删除成功<li><a href="&Request.ServerVariables("http_referer")&">"&Request.ServerVariables("http_referer")&"</a><li><a href=Default.asp>返回社区首页</a>"
succeed(""&Message&"<meta http-equiv=refresh content=3;url="&Request.ServerVariables("http_referer")&">")


end select
%>
<div class="mainnav">
<table cellspacing=1 cellpadding=5 border=0 width=100% class=a2>
<tr class=a3>
<td>&nbsp;<img src=images/Forum_nav.gif>&nbsp; <%ClubTree%> → 控制面板</td>
</tr>
</table>
<br>

<table cellspacing=1 cellpadding=5 border=0 width=100% class=a2>
	<TR id=TableTitleLink class=a1>
		<Td align="center"><b><a href="UserCp.asp">控制面板</a></b></td>
		<TD align="center"><b><a href="EditProfile.asp">资料修改</a></b></td>
		<TD align="center"><b><a href="EditProfile.asp?menu=pass">密码修改</a></b></td>
		<TD align="center"><b><a href="MySettings.asp">个性设置</a></b></td>
		<TD align="center"><b><a href="MyUpFiles.asp">上传管理</a></b></td>
		<TD align="center"><b><a href="MyFavorites.asp">管理书签</a></b></td>
		<TD align="center"><b><a href="MyMessage.asp">短信服务</a></b></td>
		<TD align="center"><b><a href="MyFriend.asp">好友列表</a></b></td>
	</TR>
</TABLE>
<br>


<%

select case Request("menu")
case ""
Default
case "Edit"
Edit
end select


Sub Edit
sql="select DISTINCT Category from [BBSXP_Favorites] where UserName='"&CookieUserName&"'"
Set Rs=Conn.Execute(sql)
Do While Not RS.EOF
if Rs("Category")<>empty then
CategoryList=CategoryList&"<option value='"&Rs("Category")&"'>"&Rs("Category")&"</option>"
end if
Rs.MoveNext
loop
Set Rs = Nothing


Set Rs=Conn.Execute("Select * from [BBSXP_Favorites] where UserName='"&CookieUserName&"' and id="&id&"")

%>
<form method=Post name=form action=MyFavorites.asp><input type=hidden name=menu value=EditUp>
<input type=hidden name=ID value=<%=id%>>
<table cellspacing=1 cellpadding=5 border=0 width=100% class=a2>
<tr>
<td colSpan="2"  class=a1 align="center"><b>编辑链接</b></td></tr><tr class=a3>
<td width="50%"><b>名称：</b><INPUT size=40 name=name value="<%=RS("name")%>"></td>
<td width="50%"><b>地址：</b><INPUT size=40 name=url value="<%=RS("url")%>"></td>
</tr>
<tr class=a3>
<td width="50%"><b>类别：</b><select name="Category">
<option value="">无</option>
<%
sql="select DISTINCT Category from [BBSXP_Favorites] where UserName='"&CookieUserName&"'"
Set Rs1=Conn.Execute(sql)
Do While Not RS1.EOF
if Rs1("Category")<>empty then
%>
<option value="<%=Rs1("Category")%>" <%if RS("Category")=Rs1("category") then%>selected<%end if%>><%=Rs1("Category")%></option>
<%
end if
Rs1.MoveNext
loop
Set Rs1 = Nothing	
%>
  </select> <a onclick="ChangeCategory();return false;" href="#">添加类别</a>
</td>
<td width="50%"><b>描述：</b><INPUT size=40 name=Description value="<%=RS("Description")%>"></td>
</tr>
<tr class=a3>
<td colspan="2" align="center"><INPUT type=submit value=" 编 辑 ">
<input type="reset" value=" 重 填 "></td>
</tr></table>
</form>

<%
Set Rs = Nothing

end Sub


Sub Default

%>



<table cellspacing=1 cellpadding=5 border=0 width=100% class=a2>
<tr><td colSpan="5"  class=a3 align="center">
<%
sql="select DISTINCT Category from [BBSXP_Favorites] where UserName='"&CookieUserName&"'"
Set Rs=Conn.Execute(sql)
Do While Not RS.EOF
if Rs("Category")<>empty then
response.write "[<a href=?Category="&Rs("Category")&">"&Rs("Category")&"</a>] "
CategoryList=CategoryList&"<option value='"&Rs("Category")&"'>"&Rs("Category")&"</option>"
end if
Rs.MoveNext
loop
Set Rs = Nothing
%>
</td></tr>
<tr class=a1><td width="10%" align="center"><b>类别</b></td>
	<td width="50%" align="center"><b>名称</b></td>
	<td width="20%" align="center">
		<b>添加时间</b></td>
	<td width="10%" align="center">编辑</td>
	<td width="10%" align="center">删除</td></tr><%
if Category<>"" then SQLCategory="and Category='"&Category&"'"

sql="[BBSXP_Favorites] where UserName='"&CookieUserName&"' "&SQLCategory&""
Set Rs=Conn.Execute(""&sql&" order by id Desc")
TotalCount=conn.Execute("Select count(ID) From "&sql&" ")(0) '获取数据数量

PageSetup=20 '设定每页的显示数量
TotalPage=Abs(Int(TotalCount/PageSetup*(-1))) '总页数
PageCount = cint(Request.QueryString("PageIndex")) '获取当前页
if PageCount <1 then PageCount = 1
if PageCount > TotalPage then PageCount = TotalPage
if TotalPage>1 then RS.Move (PageCount-1) * pagesetup

i=0 
Do While Not Rs.EOF and i<PageSetup 
i=i+1 

%> <tr class=a3><td align="center"><%=Rs("category")%></td><td><img src=images/ie.gif> <a target=_blank href="<%=Rs("url")%>"><%=Rs("name")%></a><br><font color=808080><%=Rs("Description")%></font></td>
	<td align=center ><%=Rs("DateCreated")%><td align=center>
	<a href="?menu=Edit&id=<%=Rs("id")%>"><img src=images/edit.gif border=0></a></td><td align=center><a onclick="return confirm('您确定要删除该链接?')" href="?menu=Delweb&id=<%=Rs("id")%>"><img src=images/delete.gif border=0></a></td></tr><%          
Rs.MoveNext
loop
Set Rs = Nothing
%>
</table>
<table cellspacing=0 cellpadding=0 border=0 width=100%>
<tr>
<td>
<%ShowPage()%>
</td>
</tr>
</table>

<br>

<form method=Post name=form action=MyFavorites.asp><input type=hidden name=menu value=add>
<table cellspacing=1 cellpadding=5 border=0 width=100% class=a2>
<tr>
<td colSpan="2"  class=a1 align="center"><b>添加链接</b></td></tr><tr class=a3>
<td width="50%"><b>名称：</b><INPUT size=40 name=name></td>
<td width="50%"><b>地址：</b><INPUT size=40 name=url value="http://"></td>
</tr>
<tr class=a3>
<td width="50%"><b>类别：</b><select name="Category">
<option value="">无</option>
	<%=CategoryList%>
  </select> <a onclick="ChangeCategory();return false;" href="#">添加类别</a> </td>
<td width="50%"><b>描述：</b><INPUT size=40 name="Description"></td>
</tr>
<tr class=a3>
<td colspan="2" align="center"><INPUT type=submit value=" 添 加 ">
<input type="reset" value=" 重 填 "></td>
</tr></table></div>
</form>

<%
end sub
htmlend
%>