<!--#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_Word",0)

Dim Fk_Word_Name,Fk_Word_Url,Fk_Word_ReplaceCount

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

Select Case Types
	Case 1
		Call WordList() '站内关键字列表
	Case 2
		Call WordAddForm() '添加站内关键字表单
	Case 3
		Call WordAddDo() '执行添加站内关键字
	Case 4
		Call WordEditForm() '修改站内关键字表单
	Case 5
		Call WordEditDo() '执行修改站内关键字
	Case 6
		Call WordDelDo() '执行删除站内关键字
	Case Else
		Call FKFun.ShowErr("未发现功能项！",1)
End Select

'==========================================
'函 数 名：WordList()
'作    用：站内关键字列表
'==========================================
Sub WordList()
	PageNow=Request.QueryString("Page")
	If PageNow<>"" Then
		PageNow=Clng(PageNow)
	Else
		PageNow=1
	End If
	
	Response.Cookies("url_f02")=FKFun.GetNowUrl()
%>
		<div id="rightNav">
			<ul>
				<li><a href="Word.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">序号</th>
				<th align="center">关键字</th>
				<th align="center">链接</th>
				<th align="center">替换次数</th>
				<th align="center">操作</th>
			</tr>
<%
	Dim Fk_Word_ReplaceCount
	Sqlstr="Select Fk_Word_Id,Fk_Word_Name,Fk_Word_Url,Fk_Word_ReplaceCount From [Fk_Word] Order By Fk_Word_Id Asc"
	Rs.Open Sqlstr,Conn,1,1
	If Not Rs.Eof Then
		i=1+(PageNow-1)*PageSizes
		Rs.PageSize=PageSizes
		If PageNow>Rs.PageCount Or PageNow<=0 Then
			PageNow=1
		End If
		PageCounts=Rs.PageCount
		Rs.AbsolutePage=PageNow
		PageRecordCount=Rs.RecordCount
		j=1
		While (Not Rs.Eof) And j<PageSizes+1
			If Rs("Fk_Word_ReplaceCount")=0 Then
				Fk_Word_ReplaceCount="所有"
			Else
				Fk_Word_ReplaceCount=Rs("Fk_Word_ReplaceCount")&"次"
			End If
%>
			<tr>
				<td height="20" align="center"><%=i%></td>
				<td align="center"><%=Rs("Fk_Word_Name")%></td>
				<td align="center"><%=Rs("Fk_Word_Url")%></td>
				<td align="center"><%=Fk_Word_ReplaceCount%></td>
				<td align="center"><a href="Word.asp?Type=4&Id=<%=Rs("Fk_Word_Id")%>" target="dialog" width="500">修改</a> <a href="Word.asp?Type=6&Id=<%=Rs("Fk_Word_Id")%>" target="delete" confirmStr="您确认要删除“<%=Rs("Fk_Word_Name")%>”？此操作不可逆！" refreshUrl="<%=Request.Cookies("url_f02")%>" showStr="名称删除成功！">删除</a></td>
			</tr>
<%
			Rs.MoveNext
			i=i+1
			j=j+1
		Wend
	Else
%>
			<tr>
				<td height="25" colspan="20" align="center">暂无记录</td>
			</tr>
<%
	End If
	Rs.Close
%>
			<tr>
				<td height="30" colspan="20">
					&nbsp;&nbsp;<%Call FKFun.ShowPageCode("Word.asp?Type=1&Page=",PageNow,PageRecordCount,PageSizes,PageCounts)%>
				</td>
			</tr>
		</table>
		<div id="rightBottom">
		
		</div>
<%
End Sub

'==========================================
'函 数 名：WordAddForm()
'作    用：添加站内关键字表单
'==========================================
Sub WordAddForm()
%>
<form id="WordAdd" name="WordAdd" method="post" target="ajax" action="Word.asp?Type=3" showStr="新站内关键字添加成功！" refreshUrl="Word.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_Word_Name" type="text" class="input" id="Fk_Word_Name" /><span class="help" title="<p>站内关键字名称，请输入1-50个字符（两个字符为一个汉字）。</p>"></span></td>
		</tr>
		<tr>
			<td width="24%" height="30" align="right">链接：</td>
			<td width="76%">&nbsp;<input name="Fk_Word_Url" type="text" class="input" id="Fk_Word_Url" /><span class="help" title="<p>链接地址，请输入1-255个字符（两个字符为一个汉字）。</p>"></span></td>
		</tr>
		<tr>
			<td width="24%" height="30" align="right">替换次数：</td>
			<td width="76%">&nbsp;<input name="Fk_Word_ReplaceCount" type="text" class="input" id="Fk_Word_ReplaceCount" value="2" size="5" /> 次<span class="help" title="<p>关键字链接替换次数，0为不限制。</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

'==============================
'函 数 名：WordAddDo
'作    用：执行添加站内关键字
'==============================
Sub WordAddDo()
	Fk_Word_Name=FKFun.HTMLEncode(Trim(Request.Form("Fk_Word_Name")))
	Fk_Word_Url=FKFun.HTMLEncode(Trim(Request.Form("Fk_Word_Url")))
	Fk_Word_ReplaceCount=Trim(Request.Form("Fk_Word_ReplaceCount"))
	Call FKFun.JsonString(Fk_Word_Name,1,50,0,"请输入名称！","名称不能大于50个字符！")
	Call FKFun.JsonString(Fk_Word_Url,1,50,0,"请输入链接地址！","链接地址不能大于50个字符！")
	Call FKFun.JsonNum(Fk_Word_ReplaceCount,"替换次数必须是数字！")
	Sqlstr="Select Fk_Word_Id,Fk_Word_Name,Fk_Word_Url,Fk_Word_ReplaceCount,Fk_Word_Len From [Fk_Word] Where Fk_Word_Name='"&Fk_Word_Name&"'"
	Rs.Open Sqlstr,Conn,1,3
	If Rs.Eof Then
		Application.Lock()
		Rs.AddNew()
		Rs("Fk_Word_Name")=Fk_Word_Name
		Rs("Fk_Word_Url")=Fk_Word_Url
		Rs("Fk_Word_ReplaceCount")=Fk_Word_ReplaceCount
		Rs("Fk_Word_Len")=Len(Fk_Word_Name)
		Rs.Update()
		Application.UnLock()
		Call FKFun.JsonSuccess()
	Else
		Rs.Close
		Call FKFun.JsonError("该站内关键字名称已经被占用！")
	End If
	Rs.Close
End Sub

'==========================================
'函 数 名：WordEditForm()
'作    用：修改站内关键字表单
'==========================================
Sub WordEditForm()
	Id=Clng(Request.QueryString("Id"))
	Sqlstr="Select Fk_Word_Name,Fk_Word_Url,Fk_Word_ReplaceCount From [Fk_Word] Where Fk_Word_Id=" & Id
	Rs.Open Sqlstr,Conn,1,1
	If Not Rs.Eof Then
		Fk_Word_Name=Rs("Fk_Word_Name")
		Fk_Word_Url=Rs("Fk_Word_Url")
		Fk_Word_ReplaceCount=Rs("Fk_Word_ReplaceCount")
	Else
		Rs.Close
		Call FKFun.ShowErr("站内关键字不存在！",1)
	End If
	Rs.Close
%>
<form id="WordEdit" name="WordEdit" method="post" target="ajax" action="Word.asp?Type=5" showStr="站内关键字修改成功！" refreshUrl="<%=Request.Cookies("url_f02")%>" 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_Word_Name" type="text" class="input" id="Fk_Word_Name" value="<%=Fk_Word_Name%>" /><span class="help" title="<p>站内关键字名称，请输入1-50个字符（两个字符为一个汉字）。</p>"></span></td>
		</tr>
		<tr>
			<td width="24%" height="30" align="right">链接：</td>
			<td width="76%">&nbsp;<input name="Fk_Word_Url" type="text" class="input" id="Fk_Word_Url" value="<%=Fk_Word_Url%>" /><span class="help" title="<p>链接地址，请输入1-255个字符（两个字符为一个汉字）。</p>"></span></td>
		</tr>
		<tr>
			<td width="24%" height="30" align="right">替换次数：</td>
			<td width="76%">&nbsp;<input name="Fk_Word_ReplaceCount" type="text" class="input" id="Fk_Word_ReplaceCount" value="<%=Fk_Word_ReplaceCount%>" size="5" /> 次<span class="help" title="<p>关键字链接替换次数，0为不限制。</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

'==============================
'函 数 名：WordEditDo
'作    用：执行修改站内关键字
'==============================
Sub WordEditDo()
	Fk_Word_Name=FKFun.HTMLEncode(Trim(Request.Form("Fk_Word_Name")))
	Fk_Word_Url=FKFun.HTMLEncode(Trim(Request.Form("Fk_Word_Url")))
	Fk_Word_ReplaceCount=Trim(Request.Form("Fk_Word_ReplaceCount"))
	Id=Trim(Request.Form("Id"))
	Call FKFun.JsonString(Fk_Word_Name,1,50,0,"请输入名称！","名称不能大于50个字符！")
	Call FKFun.JsonString(Fk_Word_Url,1,50,0,"请输入链接地址！","链接地址不能大于50个字符！")
	Call FKFun.JsonNum(Fk_Word_ReplaceCount,"替换次数必须是数字！")
	Call FKFun.JsonNum(Id,"系统参数错误，请刷新页面！")
	Sqlstr="Select Fk_Word_Id,Fk_Word_Name,Fk_Word_Url,Fk_Word_ReplaceCount,Fk_Word_Len From [Fk_Word] Where Fk_Word_Id=" & Id
	Rs.Open Sqlstr,Conn,1,3
	If Not Rs.Eof Then
		Application.Lock()
		Rs("Fk_Word_Name")=Fk_Word_Name
		Rs("Fk_Word_Url")=Fk_Word_Url
		Rs("Fk_Word_ReplaceCount")=Fk_Word_ReplaceCount
		Rs("Fk_Word_Len")=Len(Fk_Word_Name)
		Rs.Update()
		Application.UnLock()
		Call FKFun.JsonSuccess()
	Else
		Rs.Close
		Call FKFun.JsonError("要修改的站内关键字不存在！")
	End If
	Rs.Close
End Sub

'==============================
'函 数 名：WordDelDo
'作    用：执行删除站内关键字
'==============================
Sub WordDelDo()
	Id=Trim(Request.QueryString("Id"))
	Call FKFun.ShowNum(Id,"系统参数错误，请刷新页面！")
	Sqlstr="Select Fk_Word_Id From [Fk_Word] Where Fk_Word_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()
%>
