<!--#Include File="Include.asp"--><%
'--------------------------------------
'Power By 580Web @2010-2014 f02
'URL:http://www.580Web.Cn/
'EMail:wsok85@qq.com
'QQ:253819801
'版权所有 未经允许不得去除本版权信息
'--------------------------------------

Call CheckAdminType("0,1",UType)
Call CheckAdminLimit(ULimit,"o_Friends",0)

Dim Fk_Friends_Name,Fk_Friends_About,Fk_Friends_Url,Fk_Friends_Logo,Fk_Friends_ShowType,Fk_Friends_FriendsType

Types=Clng(Request.QueryString("Type"))

Select Case Types
	Case 1
		Call FriendsList() '友情链接列表
	Case 2
		Call FriendsAddForm() '添加友情链接表单
	Case 3
		Call FriendsAddDo() '执行添加友情链接
	Case 4
		Call FriendsEditForm() '修改友情链接表单
	Case 5
		Call FriendsEditDo() '执行修改友情链接
	Case 6
		Call FriendsDelDo() '执行删除友情链接
	Case Else
		Call FKFun.ShowErr("未发现功能项！",1)
End Select

'==========================================
'函 数 名：FriendsList()
'作    用：友情链接列表
'==========================================
Sub FriendsList()
%>
		<div id="rightNav">
			<ul>
				<li><a href="Friends.asp?Type=2" target="dialog" width="500">添加友情链接</a></li>
			</ul>
		</div>
		<div id="searchLine" class="font_bold">
			友情链接管理
		</div>
		<table width="100%" bordercolor="#CCCCCC" border="1" cellspacing="0" cellpadding="0">
			<tr>
				<th align="center">ID</th>
				<th align="center">名称</th>
				<th align="center">LOGO</th>
				<th align="center">显示模式</th>
				<th align="center">所属类型</th>
				<th align="center">操作</th>
			</tr>
<%
	Sqlstr="Select Fk_Friends_Id,Fk_Friends_Name,Fk_Friends_Logo,Fk_Friends_ShowType,Fk_FriendsType_Name From [Fk_FriendsList] Order By Fk_Friends_Id Desc"
	Rs.Open Sqlstr,Conn,1,1
	If Not Rs.Eof Then
		i=1
		While Not Rs.Eof
			If Rs("Fk_Friends_Logo")<>"" Then
				Fk_Friends_Logo="<img src='"&Rs("Fk_Friends_Logo")&"' width='88' height='31' />"
			Else
				Fk_Friends_Logo="-"
			End If
%>
			<tr>
				<td height="20" align="center"><%=Rs("Fk_Friends_Id")%></td>
				<td align="center"><%=Rs("Fk_Friends_Name")%></td>
				<td align="center"><%=Fk_Friends_Logo%></td>
				<td align="center"><%=FKFun.GetFriendsShowTypeName(Rs("Fk_Friends_ShowType"))%></td>
				<td align="center"><%=Rs("Fk_FriendsType_Name")%></td>
				<td align="center"><a href="Friends.asp?Type=4&Id=<%=Rs("Fk_Friends_Id")%>" target="dialog" width="500">修改</a> <a href="Friends.asp?Type=6&Id=<%=Rs("Fk_Friends_Id")%>" target="delete" confirmStr="您确认要删除“<%=Rs("Fk_Friends_Name")%>”？此操作不可逆！" refreshUrl="Friends.asp?Type=1" showStr="名称删除成功！">删除</a></td>
			</tr>
<%
			Rs.MoveNext
			i=i+1
		Wend
	Else
%>
			<tr>
				<td height="25" colspan="20" align="center">暂无记录</td>
			</tr>
<%
	End If
	Rs.Close
%>
			<tr>
				<td height="30" colspan="20">&nbsp;</td>
			</tr>
		</table>
		<div id="rightBottom">
		
		</div>
<%
End Sub

'==========================================
'函 数 名：FriendsAddForm()
'作    用：添加友情链接表单
'==========================================
Sub FriendsAddForm()
%>
<form id="FriendsAdd" name="FriendsAdd" method="post" target="ajax" action="Friends.asp?Type=3" showStr="新友情链接添加成功！" refreshUrl="Friends.asp?Type=1" boxClose="1">
<div id="title">添加新友情链接</div>
<div id="box">
	<table width="90%" border="1" bordercolor="#CCCCCC" align="center" cellpadding="0" cellspacing="0">
		<tr>
			<td width="24%" height="30" align="right">名称：</td>
			<td width="76%">&nbsp;<input name="Fk_Friends_Name" type="text" class="input" id="Fk_Friends_Name" /><span class="help" title="<p>友情链接名称，请输入1-50个字符（两个字符为一个汉字）。</p>"></span></td>
		</tr>
		<tr>
			<td height="30" align="right">简介：</td>
			<td>&nbsp;<input name="Fk_Friends_About" type="text" class="input" id="Fk_Friends_About" /><span class="help" title="<p>对方站点的简介，可留空，请输入0-255个字符（1个汉字为2个字符）。</p>"></span></td>
		</tr>
		<tr>
			<td height="30" align="right">网址：</td>
			<td>&nbsp;<input name="Fk_Friends_Url" type="text" class="input" id="Fk_Friends_Url" value="http://" /><span class="help" title="<p>对方站点链接，请用http://开头，可输入1-255个字符。</p>"></span></td>
		</tr>
		<tr>
			<td height="30" align="right">LOGO：</td>
			<td>&nbsp;<input name="Fk_Friends_Logo" type="text" class="input" id="Fk_Friends_Logo" /> <input type="button" class="picList_btn btnUpload" name="btnLogo" id="btnLogo" value="上传LOGO" callback="2" inputId="Fk_Friends_Logo" fileAction="Upload.asp?immediate=3" /><span class="help" title="<p>对方站点的LOGO，可留空，请输入0-255个字符，可以输入链接，也可以上传到空间。</p>"></span></td>
		</tr>
		<tr>
			<td height="30" align="right">显示模式：</td>
			<td>&nbsp;<input name="Fk_Friends_ShowType" class="input" type="radio" id="Fk_Friends_ShowType" value="1" checked="checked" />LOGO
            	<input type="radio" name="Fk_Friends_ShowType" class="Input" id="Fk_Friends_ShowType" value="2" />文字<span class="help" title="<p>设置显示模式为文字或者LOGO。</p>"></span>
			</td>
		</tr>
		<tr>
			<td height="30" align="right">所属类型：</td>
			<td>&nbsp;<select name="Fk_Friends_FriendsType" class="input" id="Fk_Friends_FriendsType">
<%
	Sqlstr="Select Fk_FriendsType_Id,Fk_FriendsType_Name From [Fk_FriendsType] Order By Fk_FriendsType_Id Asc"
	Rs.Open Sqlstr,Conn,1,1
	While Not Rs.Eof
%>
					<option value="<%=Rs("Fk_FriendsType_Id")%>"><%=Rs("Fk_FriendsType_Name")%></option>
<%
		Rs.MoveNext
	Wend
	Rs.Close
%>
                </select><span class="help" title="<p>选择友情链接类型。</p>"></span>
			</td>
		</tr>
	</table>
</div>
<div id="bottom">
	<input type="submit" class="button" name="Enter" id="Enter" value="添 加" />
	<input type="button" onclick="dialogClose();" class="button" name="button" id="button" value="关 闭" />
</div>
</form>
<%
End Sub

'==============================
'函 数 名：FriendsAddDo
'作    用：执行添加友情链接
'==============================
Sub FriendsAddDo()
	Fk_Friends_Name=FKFun.HTMLEncode(Trim(Request.Form("Fk_Friends_Name")))
	Fk_Friends_About=FKFun.HTMLEncode(Trim(Request.Form("Fk_Friends_About")))
	Fk_Friends_Url=FKFun.HTMLEncode(Trim(Request.Form("Fk_Friends_Url")))
	Fk_Friends_Logo=FKFun.HTMLEncode(Trim(Request.Form("Fk_Friends_Logo")))
	Fk_Friends_ShowType=Trim(Request.Form("Fk_Friends_ShowType"))
	Fk_Friends_FriendsType=Trim(Request.Form("Fk_Friends_FriendsType"))
	Call FKFun.JsonString(Fk_Friends_Name,1,50,0,"请输入友情链接名称！","友情链接名称不能大于255个字符！")
	Call FKFun.JsonString(Fk_Friends_About,1,255,2,"请输入友情链接介绍！","友情链接介绍不能大于255个字符！")
	Call FKFun.JsonString(Fk_Friends_Url,1,255,0,"请输入友情链接网址！","友情链接网址不能大于255个字符！")
	Call FKFun.JsonString(Fk_Friends_Logo,1,255,2,"请输入友情链接LOGO！","友情链接LOGO不能大于255个字符！")
	Call FKFun.JsonNum(Fk_Friends_ShowType,"请选择显示模式！")
	Call FKFun.JsonNum(Fk_Friends_FriendsType,"请选择所属类型！")
	Sqlstr="Select Fk_Friends_Id,Fk_Friends_Name,Fk_Friends_About,Fk_Friends_Url,Fk_Friends_Logo,Fk_Friends_ShowType,Fk_Friends_FriendsType From [Fk_Friends] Where Fk_Friends_Name='"&Fk_Friends_Name&"' And Fk_Friends_Url='"&Fk_Friends_Url&"'"
	Rs.Open Sqlstr,Conn,1,3
	If Rs.Eof Then
		Application.Lock()
		Rs.AddNew()
		Rs("Fk_Friends_Name")=Fk_Friends_Name
		Rs("Fk_Friends_About")=Fk_Friends_About
		Rs("Fk_Friends_Url")=Fk_Friends_Url
		Rs("Fk_Friends_Logo")=Fk_Friends_Logo
		Rs("Fk_Friends_ShowType")=Fk_Friends_ShowType
		Rs("Fk_Friends_FriendsType")=Fk_Friends_FriendsType
		Rs.Update()
		Application.UnLock()
		Call FKFun.JsonSuccess()
	Else
		Rs.Close
		Call FKFun.JsonError("该友情链接已经存在！")
	End If
	Rs.Close
End Sub

'==========================================
'函 数 名：FriendsEditForm()
'作    用：修改友情链接表单
'==========================================
Sub FriendsEditForm()
	Id=Clng(Request.QueryString("Id"))
	Sqlstr="Select Fk_Friends_Name,Fk_Friends_About,Fk_Friends_Url,Fk_Friends_Logo,Fk_Friends_ShowType,Fk_Friends_FriendsType From [Fk_Friends] Where Fk_Friends_Id=" & Id
	Rs.Open Sqlstr,Conn,1,1
	If Not Rs.Eof Then
		Fk_Friends_Name=Rs("Fk_Friends_Name")
		Fk_Friends_About=Rs("Fk_Friends_About")
		Fk_Friends_Url=Rs("Fk_Friends_Url")
		Fk_Friends_Logo=Rs("Fk_Friends_Logo")
		Fk_Friends_ShowType=Rs("Fk_Friends_ShowType")
		Fk_Friends_FriendsType=Rs("Fk_Friends_FriendsType")
	Else
		Rs.Close
		Call FKFun.ShowErr("友情链接不存在！",1)
	End If
	Rs.Close
%>
<form id="FriendsEdit" name="FriendsEdit" method="post" target="ajax" action="Friends.asp?Type=5" showStr="友情链接修改成功！" refreshUrl="Friends.asp?Type=1" boxClose="1">
<div id="title">修改友情链接</div>
<div id="box">
	<table width="90%" border="1" bordercolor="#CCCCCC" align="center" cellpadding="0" cellspacing="0">
		<tr>
			<td width="24%" height="30" align="right">名称：</td>
			<td width="76%">&nbsp;<input name="Fk_Friends_Name" type="text" class="input" id="Fk_Friends_Name" value="<%=Fk_Friends_Name%>" /><span class="help" title="<p>友情链接名称，请输入1-50个字符（两个字符为一个汉字）。</p>"></span></td>
		</tr>
		<tr>
			<td height="30" align="right">简介：</td>
			<td>&nbsp;<input name="Fk_Friends_About" type="text" class="input" id="Fk_Friends_About" value="<%=Fk_Friends_About%>" /><span class="help" title="<p>对方站点的简介，可留空，请输入0-255个字符（1个汉字为2个字符）。</p>"></span></td>
		</tr>
		<tr>
			<td height="30" align="right">网址：</td>
			<td>&nbsp;<input name="Fk_Friends_Url" type="text" class="input" id="Fk_Friends_Url" value="<%=Fk_Friends_Url%>" /><span class="help" title="<p>对方站点链接，请用http://开头，可输入1-255个字符。</p>"></span></td>
		</tr>
		<tr>
			<td height="30" align="right">LOGO：</td>
			<td>&nbsp;<input name="Fk_Friends_Logo" type="text" class="input" id="Fk_Friends_Logo" value="<%=Fk_Friends_Logo%>" /> <input type="button" class="picList_btn btnUpload" name="btnLogo" id="btnLogo" value="上传LOGO" callback="2" inputId="Fk_Friends_Logo" fileAction="Upload.asp?immediate=3" /><span class="help" title="<p>对方站点的LOGO，可留空，请输入0-255个字符，可以输入链接，也可以上传到空间。</p>"></span></td>
		</tr>
		<tr>
			<td height="30" align="right">显示模式：</td>
			<td>&nbsp;<input name="Fk_Friends_ShowType" class="input" type="radio" id="Fk_Friends_ShowType" value="1"<%=FKFun.BeCheck(Fk_Friends_ShowType,1)%> />LOGO
            	<input type="radio" name="Fk_Friends_ShowType" class="Input" id="Fk_Friends_ShowType" value="2"<%=FKFun.BeCheck(Fk_Friends_ShowType,2)%> />文字<span class="help" title="<p>设置显示模式为文字或者LOGO。</p>"></span>
			</td>
		</tr>
		<tr>
			<td height="30" align="right">所属类型：</td>
			<td>&nbsp;<select name="Fk_Friends_FriendsType" class="input" id="Fk_Friends_FriendsType">
<%
	Sqlstr="Select Fk_FriendsType_Id,Fk_FriendsType_Name From [Fk_FriendsType] Order By Fk_FriendsType_Id Asc"
	Rs.Open Sqlstr,Conn,1,1
	While Not Rs.Eof
%>
					<option value="<%=Rs("Fk_FriendsType_Id")%>"<%=FKFun.BeSelect(Rs("Fk_FriendsType_Id"),Fk_Friends_FriendsType)%>><%=Rs("Fk_FriendsType_Name")%></option>
<%
		Rs.MoveNext
	Wend
	Rs.Close
%>
                </select><span class="help" title="<p>选择友情链接类型。</p>"></span>
			</td>
		</tr>
	</table>
</div>
<div id="bottom">
	<input type="hidden" name="Id" value="<%=Id%>" />
	<input type="submit" class="button" name="Enter" id="Enter" value="修 改" />
	<input type="button" onclick="dialogClose();" class="button" name="button" id="button" value="关 闭" />
</div>
</form>
<%
End Sub

'==============================
'函 数 名：FriendsEditDo
'作    用：执行修改友情链接
'==============================
Sub FriendsEditDo()
	Fk_Friends_Name=FKFun.HTMLEncode(Trim(Request.Form("Fk_Friends_Name")))
	Fk_Friends_About=FKFun.HTMLEncode(Trim(Request.Form("Fk_Friends_About")))
	Fk_Friends_Url=FKFun.HTMLEncode(Trim(Request.Form("Fk_Friends_Url")))
	Fk_Friends_Logo=FKFun.HTMLEncode(Trim(Request.Form("Fk_Friends_Logo")))
	Fk_Friends_ShowType=Trim(Request.Form("Fk_Friends_ShowType"))
	Fk_Friends_FriendsType=Trim(Request.Form("Fk_Friends_FriendsType"))
	Id=Trim(Request.Form("Id"))
	Call FKFun.JsonString(Fk_Friends_Name,1,50,0,"请输入友情链接名称！","友情链接名称不能大于255个字符！")
	Call FKFun.JsonString(Fk_Friends_About,1,255,2,"请输入友情链接介绍！","友情链接介绍不能大于255个字符！")
	Call FKFun.JsonString(Fk_Friends_Url,1,255,0,"请输入友情链接网址！","友情链接网址不能大于255个字符！")
	Call FKFun.JsonString(Fk_Friends_Logo,1,255,2,"请输入友情链接LOGO！","友情链接LOGO不能大于255个字符！")
	Call FKFun.JsonNum(Fk_Friends_ShowType,"请选择显示模式！")
	Call FKFun.JsonNum(Fk_Friends_FriendsType,"请选择所属类型！")
	Call FKFun.JsonNum(Id,"系统参数错误，请刷新页面！")
	Sqlstr="Select Fk_Friends_Id,Fk_Friends_Name,Fk_Friends_About,Fk_Friends_Url,Fk_Friends_Logo,Fk_Friends_ShowType,Fk_Friends_FriendsType From [Fk_Friends] Where Fk_Friends_Id=" & Id
	Rs.Open Sqlstr,Conn,1,3
	If Not Rs.Eof Then
		Application.Lock()
		Rs("Fk_Friends_Name")=Fk_Friends_Name
		Rs("Fk_Friends_About")=Fk_Friends_About
		Rs("Fk_Friends_Url")=Fk_Friends_Url
		Rs("Fk_Friends_Logo")=Fk_Friends_Logo
		Rs("Fk_Friends_ShowType")=Fk_Friends_ShowType
		Rs("Fk_Friends_FriendsType")=Fk_Friends_FriendsType
		Rs.Update()
		Application.UnLock()
		Call FKFun.JsonSuccess()
	Else
		Rs.Close
		Call FKFun.JsonError("要修改的友情链接不存在！")
	End If
	Rs.Close
End Sub

'==============================
'函 数 名：FriendsDelDo
'作    用：执行删除友情链接
'==============================
Sub FriendsDelDo()
	Id=Trim(Request.QueryString("Id"))
	Call FKFun.ShowNum(Id,"系统参数错误，请刷新页面！")
	Sqlstr="Select Fk_Friends_Id From [Fk_Friends] Where Fk_Friends_Id=" & Id
	Rs.Open Sqlstr,Conn,1,3
	If Not Rs.Eof Then
		Application.Lock()
		Rs.Delete()
		Application.UnLock()
		Response.Write("ok")
	Else
		Response.Write("要删除的友情链接不存在！")
	End If
	Rs.Close
End Sub

Call FKFun.PageEnd()
%>
