<%@language=vbscript codepage=936 %>
<%
option explicit
response.buffer=true
%>
<!--#include file="../Conn.asp"-->
<!--#include file="../Inc/Cl_ClsSysTem.asp"-->
<!--#include file="../Inc/Cl_Function_Public.asp"-->
<%
Const ChannelID=1
Const MaxPerPage=20
Const MaxFavNum=50
Cl.GetWeb_Setting()
If Not Cl.ChkUserLogin Then
	User_ShowErr("<li>以下操作需要登录后方或进行，您未登录。</li><li>请点击<a href='LogIn.asp' target='_Top'>这里登录</a>。")
	Response.End
End If

Dim Action,Rs,SQL,i
Dim TotalPut,CurrentPage,TotalPages

Action		= Trim(request("Action"))
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>用户收藏夹</title>
<link rel="stylesheet" type="text/css" href="../Skins/User_Style.Css">
<script language = "JavaScript" src="../Inc/Js/Admin.js"></script>
</head>
<body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0">
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" Class="border">  
	<tr class="title"><td height="22" align=center><b>用 户 收 藏 夹</b></td></tr>
	<tr class="tdbg" onMouseOut="this.className='tdbg'" onMouseOver="this.className='tdbg2'">
	<td height="22" align=left>
		&nbsp;&nbsp;&nbsp;&nbsp;<a href="User_Favorite.Asp?Action=MyFav">我的收藏</a>&nbsp;|&nbsp;<a href="User_Favorite.Asp?Action=Add">添加收藏</a>&nbsp;|&nbsp;<a href="User_Favorite.Asp?Action=Public">网友共享收藏</a>
		</td>
	</tr>
</table>
<br>
<%
Select Case Action
Case "Add","Modify"
	Call InfoFav()
Case "SaveAdd","SaveModify"
	Call SaveInfoFav()
Case "Public"
	Call PublicFav()
Case "DelFav"
	Call DelFav()
Case "MyFav"
	Call FavMain()
Case else
	Action="Add"
	Call InfoFav()
end Select

Footer

Sub FavMain()
CurrentPage	= Cl.ChkClng(request("page"))
%>
<table border="0" align="center" cellpadding="0" cellspacing="1" class="border">
    <tr class="title">
      <td align="center" Colspan=6><strong>我 的 收 藏 夹</strong></td>
    </tr>
    <tr class="tdbg" onMouseOut="this.className='tdbg'" onMouseOver="this.className='tdbg2'">
      <td align="center" width=40><strong>编号</strong></td>
      <td align="center" width=220><strong>标题</strong></td>
      <td align="center"><strong>地址</strong></td>
      <td align="center" width=60><strong>共享</strong></td>
      <td align="center" width=120><strong>添加时间</strong></td>
      <td align="center" width=80><strong>可用操作</strong></td>
    </tr>
<%
Set Rs=Server.CreateObject("adodb.recordset")
SQL="Select ID,UserID,UserName,Title,Url,ReMark,IsPublic,AddTime From Cl_Favorite Where UserID="&Cl.UserID&" Order By ID Desc"
OpenConn : Rs.Open SQL,Conn,1,1
if Rs.Bof and Rs.Eof then
%>
    <tr>
      <td align="center" Colspan=6 class=tdbg>暂无任何充值记录！</td>
    </tr>
<%
	Rs.Close : Set Rs=Nothing
else
	TotalPut=rs.recordcount
	if (TotalPut mod MaxPerPage)=0 then
		TotalPages = TotalPut \ MaxPerPage
	else
		TotalPages = TotalPut \ MaxPerPage + 1
	end if
	if CurrentPage > TotalPages then CurrentPage=TotalPages
	if CurrentPage < 1 then CurrentPage=1
	rs.move (CurrentPage-1)*MaxPerPage
	SQL		= rs.GetRows(MaxPerPage)
	rs.close : set rs=Nothing
	For i=0 To Ubound(SQL,2)
%>
    <tr class="tdbg" onMouseOut="this.className='tdbg'" onMouseOver="this.className='tdbg2'">
      <td align="center" width=40><%=SQL(0,i)%></td>
      <td width=220><%=SQL(3,i)%></td>
      <td><a href="<%="http://" & Replace(Lcase(SQL(4,i)),"http://","")%>" target="_blank"><%=SQL(4,i)%></a></td>
      <td align="center" width=60><%
	  if SQL(6,i)=1 then
	  Response.write "<font color='#ff0033'>共享</font>"
	  else
	  Response.write "<font color='#0000ff'>私有</font>"
	  end if
	  %></td>
      <td align="center" width=120><%=SQL(7,i)%></td>
      <td align="center" width=80><a href="User_Favorite.Asp?Action=Modify&ID=<%=SQL(0,i)%>">修改</a>&nbsp;&nbsp;<a href="User_Favorite.Asp?Action=DelFav&ID=<%=SQL(0,i)%>">删除</a></td>
    </tr>
<%
	Next
	SQL=Empty
End if
%>
</table>
<%
Response.write Cl.ShowPage("?Action="&Action,TotalPut,MaxPerPage,"条","记录")
End Sub

Sub PublicFav()
CurrentPage	= Cl.ChkClng(request("page"))
%>
<table border="0" align="center" cellpadding="0" cellspacing="1" class="border">
    <tr class="title">
      <td align="center" Colspan=6><strong>网 友 共 享 的 收 藏</strong></td>
    </tr>
    <tr class="tdbg" onMouseOut="this.className='tdbg'" onMouseOver="this.className='tdbg2'">
      <td align="center" width=40><strong>编号</strong></td>
      <td align="center" width=220><strong>标题</strong></td>
      <td align="center"><strong>地址</strong></td>
      <td align="center" width=80><strong>所属用户</strong></td>
      <td align="center" width=120><strong>添加时间</strong></td>
    </tr>
<%
Set Rs=Server.CreateObject("adodb.recordset")
SQL="Select ID,UserID,UserName,Title,Url,ReMark,IsPublic,AddTime From Cl_Favorite Where IsPublic=1 Order By ID Desc"
OpenConn : Rs.Open SQL,Conn,1,1
if Rs.Bof and Rs.Eof then
%>
    <tr>
      <td align="center" Colspan=6 class=tdbg>暂无任何充值记录！</td>
    </tr>
<%
	Rs.Close : Set Rs=Nothing
else
	TotalPut=rs.recordcount
	if (TotalPut mod MaxPerPage)=0 then
		TotalPages = TotalPut \ MaxPerPage
	else
		TotalPages = TotalPut \ MaxPerPage + 1
	end if
	if CurrentPage > TotalPages then CurrentPage=TotalPages
	if CurrentPage < 1 then CurrentPage=1
	rs.move (CurrentPage-1)*MaxPerPage
	SQL		= rs.GetRows(MaxPerPage)
	rs.close : set rs=Nothing
	For i=0 To Ubound(SQL,2)
%>
    <tr class="tdbg" onMouseOut="this.className='tdbg'" onMouseOver="this.className='tdbg2'">
      <td align="center" width=40><%=SQL(0,i)%></td>
      <td width=220><%=SQL(3,i)%></td>
      <td><a href="<%=SQL(4,i)%>" target="_blank"><%=SQL(4,i)%></a></td>
      <td align="center" width=80><font color="#0000ff"><%=SQL(2,i)%></font></td>
      <td align="center" width=120><%=SQL(7,i)%></td>
    </tr>
<%
	Next
	SQL=Empty
End if
%>
</table>
<%
Response.write Cl.ShowPage("?Action="&Action,TotalPut,MaxPerPage,"条","记录")
End Sub

Sub InfoFav()
Dim ID,Title,Url,ReMark,IsPublic
if Action="Modify" then
	ID=Cl.ChkClng(Request("ID"))
	If ID<=0 then Call Cl.OutMsg("请正确指定ID！","User_Favorite.asp?Action=MyFav")
	Set Rs=Cl.Execute("Select * From Cl_Favorite Where ID="&ID&"")
	If Rs.Eof then  Call Cl.OutMsg("请正确指定ID！","User_Favorite.asp?Action=MyFav")
	Title	= Rs("Title")
	Url		= Rs("Url")
	ReMark	= Rs("ReMark")
	IsPublic= Rs("IsPublic")
	Rs.Close : Set Rs=Nothing
else
	Title	= Left(Request.QueryString("Title"),250)
	Url		= Left(Request.QueryString("Url"),250)
	ReMark	= Request.QueryString("ReMark")
	IsPublic= 0
	ID		= 0
end if
%>
<script Language=javascript>
function CheckForm1()
{
	if (document.myform.Title.value=="")
	{
		alert("标题不能为空，请输入标题！");
		document.myform.Title.focus();
		return false;
	}
	if (document.myform.Url.value=="")
	{
		alert("地址不能为空，请输入完整的URL地址！");
		document.myform.Url.focus();
		return false;
	}
}
</script>
<table border="0" align="center" cellpadding="0" cellspacing="1" class="border">
<form name="myform" action="User_Favorite.asp?Action=Save<%=Action%>" method="post" onSubmit="return CheckForm1();">
    <tr>
      <td align="center" colspan="2" class="title"><strong>添 加 收 藏</strong></td>
    </tr>
    <tr class="tdbg" onMouseOut="this.className='tdbg'" onMouseOver="this.className='tdbg2'">
      <td width="100" align="right"><strong>标题：</strong></td>
      <td><input type="text" name="Title" size="60" value="<%=Title%>" maxlength=250> <font color=#ff0033>*</font></td>
    </tr>
    <tr class="tdbg" onMouseOut="this.className='tdbg'" onMouseOver="this.className='tdbg2'">
      <td width="100" align="right"><strong>地址：</strong></td>
      <td><input type="text" name="Url" size="60" value="<%=Url%>" maxlength=250> <font color=#ff0033>*</font><br><font color=#3370CC>请输入完整的URL地址</font></td>
    </tr>
    <tr class="tdbg" onMouseOut="this.className='tdbg'" onMouseOver="this.className='tdbg2'">
      <td width="100" align="right"><strong>备注：</strong></td>
      <td> 
        <textarea name="ReMark" cols="41" rows="5" id="ReMark"><%=ReMark%></textarea>
		<a href="javascript:admin_Size(-5,'ReMark')"><img src="images/minus.gif" unselectable="on" border='0'></a> <a href="javascript:admin_Size(5,'ReMark')"><img src="images/plus.gif" unselectable="on" border='0'></a><br><font color=#3370CC>请输入您的附加留言。</font>
      </td>
    </tr>
    <tr class="tdbg" onMouseOut="this.className='tdbg'" onMouseOver="this.className='tdbg2'">
      <td width="100" align="right"><strong>共享：</strong></td>
      <td> 
        <input type="radio" name="IsPublic" value="0" <%if IsPublic=0 then Response.write "checked"%>> 私有&nbsp;&nbsp&nbsp&nbsp;<input type="radio" name="IsPublic" value="1" <%if IsPublic<>0 then Response.write "checked"%>> 共享<br><font color=#3370CC>如果选择共享，那么所有网友都可以查看此收藏。</font>
      </td>
    </tr>
    <tr class="tdbg" onMouseOut="this.className='tdbg'" onMouseOver="this.className='tdbg2'">
      <td colspan=2 align="center">
		 <input type="hidden" name="ID" value="<%=ID%>">
         <input type="submit" name="Submit" value=" 添 加 ">&nbsp;&nbsp&nbsp
         <input type="button" name="reset" value=" 关 闭 " Onclick="javascript:window.close();"></td>
    </tr>
	</form>
   </table>
<%
End Sub

Sub SaveInfoFav()
Dim ID,Title,Url,ReMark,IsPublic
Title	= Request.form("Title")
Url		= Request.form("Url")
ReMark	= Request.form("ReMark")
IsPublic= Cl.ChkClng(Request.form("IsPublic"))
if Title="" or Url="" then Call Cl.OutMsg("请正确指定ID！","javascript:history.go(-1)")
if Action="SaveModify" then
	ID=Cl.ChkClng(Request("ID"))
	If ID<=0 then Call Cl.OutMsg("请正确指定ID！","User_Favorite.asp?Action=MyFav")
	Set Rs=Server.CreateObject("Adodb.recordset")
	OpenConn : Rs.Open "Select * From Cl_Favorite Where UserID="&Cl.UserID&" And ID="&ID&"",Conn,1,3
	If Rs.Eof then Call Cl.OutMsg("请正确指定ID！","User_Favorite.asp?Action=MyFav")
	Rs("Title")		= Title
	Rs("Url")		= Url
	Rs("ReMark")	= ReMark
	Rs("IsPublic")	= IsPublic
	Rs.Update
	Rs.Close : Set Rs=Nothing
	Call Cl.OutMsg("恭喜您，修改收藏成功！","User_Favorite.asp?Action=MyFav")
else
	Dim TNum
	TNum=Cl.Execute("Select Count(ID) From Cl_Favorite Where UserID="&Cl.UserID&"")(0)
	if IsNull(TNum) or Not IsNumeric(TNum) then TNum=0
	if TNum>=MaxFavNum then Call Cl.OutMsg("对不起，您的收藏夹个数已达到了最大限制（"&MaxFavNum&"个），请先清理后再添加！","User_Favorite.asp?Action=MyFav")
	TNum=Cl.Execute("Select Max(ID) From Cl_Favorite")(0)
	if IsNull(TNum) or Not IsNumeric(TNum) then TNum=0
	Set Rs=Server.CreateObject("Adodb.recordset")
	OpenConn : Rs.Open "Select Top 1 * From Cl_Favorite",Conn,1,3
	Rs.AddNew
	Rs("ID")		= TNum+1
	Rs("UserID")	= Cl.UserID
	Rs("UserName")	= Cl.MemBerName
	Rs("Title")		= Title
	Rs("Url")		= Url
	Rs("ReMark")	= ReMark
	Rs("IsPublic")	= IsPublic
	Rs("AddTime")	= Now()
	Rs.Update
	Rs.Close : Set Rs=Nothing
	Call Cl.OutMsg("恭喜您，添加收藏成功！","User_Favorite.asp?Action=MyFav")
end if
End Sub

Sub DelFav()
Dim ID
ID=Cl.ChkClng(Request("ID"))
If ID<=0 then Call Cl.OutMsg("请正确指定ID！","User_Favorite.asp?Action=MyFav")
Cl.Execute("delete * from Cl_Favorite Where UserID="&Cl.UserID&" and ID="&ID&"")
Call FavMain()
End Sub

'==================================================
'CreateLive CMS Version 3.1
'							Powered by Aspoo.Com
'
'邮箱: aspoo@126.com		Info@aspoo.cn
'ＱＱ: 3315263				596197794
'网站: www.aspoo.cn			www.aspoo.com
'论坛: bbs.aspoo.cn			bbs.aspoo.com
'
'Copyright (C) 2005 Aspoo.Com All Rights Reserved.
'==================================================
%>