<!--#include file="../conn.asp"-->
<!--#include file="admin_check.asp"-->
<!--#include file="../inc/function.asp"-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>管理页面</title>
<link id="maincss" rel="stylesheet" href="images/css/admin_style_<%= AdminSkin %>.css" type="text/css" media="all" />
</head>
<body leftmargin="0" bottommargin="0" rightmargin="0" topmargin="5" marginheight="0" marginwidth="0" bgcolor="#DDEEFF">
<%
Call chkFlag(23)
dim act,id
act=Trim(Request.QueryString("act"))
id=Trim(Request.QueryString("id"))
opendb
select case act
case "add"
  call add()
case "saveadd"
  call saveadd()
case "del"
  call del()
case "modi"
  call modi()
case "savemodi"
  call savemodi()
case else
  call main()
End select
closedb

sub del()
   conn.execute("delete from "&predb&"keylink where id="&id)
   application.Lock()
   Application("KeyLink")=""
   application.UnLock()
   Response.Write("<script>window.location.href='?'</script>")
end sub

sub saveadd()
   dim linktxt,linkurl,pai,renum
   linktxt=Trim(Request.Form("linktxt"))
   linkurl=Trim(Request.Form("linkurl"))
   renum=Trim(Request.Form("renum"))
   pai=Trim(Request.Form("pai"))
   if not IsNumeric(renum) then renum=0
   if not IsNumeric(pai) then pai=1
   if linktxt="" or linkurl="" then
      Response.Write("<script>history.go(-1)</script>")
   else
      conn.execute("insert into "&predb&"keylink(linktxt,linkurl,renum,pai) values('"&linktxt&"','"&linkurl&"',"&renum&","&pai&")")
      application.Lock()
      Application("KeyLink")=""
      application.UnLock()
	  Response.Write("<script>window.location.href='admin_keylink.asp'</script>")
   end if
end sub

sub savemodi()
   dim linktxt,linkurl,pai,renum
   linktxt=Trim(Request.Form("linktxt"))
   linkurl=Trim(Request.Form("linkurl"))
   renum=Trim(Request.Form("renum"))
   pai=Trim(Request.Form("pai"))
   if not IsNumeric(renum) then renum=0
   if not IsNumeric(pai) then pai=1
   if linktxt="" or linkurl="" then
       Response.Write("<script>history.go(-1)</scr"&"ipt>")
   else
      conn.execute("update "&predb&"keylink set linktxt='"&linktxt&"',linkurl='"&linkurl&"',renum="&renum&",pai="&pai&" where id="&id)
      Application.Lock()
	  Application("KeyLink")=""
	  Application.UnLock()
	  Response.Write("<script>window.location.href='admin_keylink.asp'</script>")
   end if
end sub

sub main()
%>
<table class="tableBorder" cellspacing="1" cellpadding="2" width="96%" align="center" border="0">
<tr>
		<th height="25" colspan="7" align="center">站内链接设置</th>
  </tr>
  <tr>
    <td colspan="7" class="TableRow2"><a href="?act=add">增加站内链接</a>&nbsp; <a href="admin_keylink.asp">站内链接首页</a></td>
  </tr>
  <tr>
    <td width="6%" align="center" class="TableRow1"><strong>选中</strong></td>
    <td width="6%" align="center" class="TableRow1"><strong>序号</strong></td>
    <td width="17%" align="center" class="TableRow1"><strong>链接目标</strong></td>
    <td align="center" class="TableRow1"><strong>链接地址</strong></td>
    <td width="8%" align="center" class="TableRow1"><strong>优先级</strong></td>
    <td width="8%" align="center" class="TableRow1"><strong>替换数</strong></td>
    <td width="17%" align="center" class="TableRow1"><strong>操作</strong></td>
  </tr>
  <form name="form1" method="post" action="">
<%
dim rs,sql,i,c
set rs= Server.CreateObject("adodb.recordset")
sql="select * from "&predb&"keylink order by id desc"
rs.open sql,conn,1,1
do while not rs.eof
i=i+1
if i mod 2=0 then c=1 else c=2
%>
  <tr>
    <td align="center" class="TableRow<%= c %>">
      <input type="checkbox" name="checkbox" id="checkbox" value="<%= rs("id") %>">    </td>
    <td class="TableRow<%= c %>"><%= rs("id") %></td>
    <td class="TableRow<%= c %>"><%= rs("linktxt") %></td>
    <td class="TableRow<%= c %>"><%= rs("linkurl") %></td>
    <td align="center" class="TableRow<%= c %>"><%= rs("pai") %></td>
    <td align="center" class="TableRow<%= c %>"><%= rs("renum") %></td>
    <td align="center" class="TableRow<%= c %>"><a href="?act=modi&id=<%=rs("id")%>">修改</a>&nbsp; <a onClick="return confirm('您确定进行删除操作吗？')" href="?act=del&id=<%=rs("id")%>">删除</a></td>
  </tr>
<%
rs.movenext
loop
rs.close
set rs=nothing
%>
  </form>
</table>
<%
end sub

sub add()
%>
<table class="tableBorder" cellspacing="1" cellpadding="2" width="96%" align="center" border="0">
<tr>
		<th height="25" colspan="2" align="center">增加站内链接</th>
  </tr>
  <tr>
    <td colspan="2" class="TableRow2"><a href="?act=add">增加站内链接</a>&nbsp; <a href="admin_keylink.asp">站内链接首页</a></td>
  </tr>
  <form name="form1" method="post" action="?act=saveadd">
  <tr>
    <td width="21%" align="center" class="TableRow1"><strong>链接文本：</strong> <font color="#FF0000">*</font></td>
    <td width="79%" class="TableRow1"><input name="linktxt" type="text" id="linktxt" size="58"></td>
  </tr>
  <tr>
    <td align="center" class="TableRow2"><strong>链接地址：</strong> <font color="#FF0000">*</font></td>
    <td class="TableRow2"><input name="linkurl" type="text" id="linkurl" size="58"></td>
  </tr>
  <tr>
    <td align="center" class="TableRow1"><strong>替换次数：</strong> <font color="#FF0000">*</font></td>
    <td class="TableRow1"><input name="reNum" type="text" id="reNum" value="0" size="6">
      &nbsp; 0为全部替换 </td>
  </tr>
  <tr>
    <td align="center" class="TableRow2"><strong>优 先 级：</strong> <font color="#FF0000">*</font></td>
    <td class="TableRow2"><input name="pai" type="text" id="pai" value="1" size="6">
      &nbsp; 数值越大优先级越高</td>
  </tr>
  <tr>
    <td align="center" class="TableRow1">&nbsp;</td>
    <td class="TableRow1"><input type="submit" name="button" id="button" value="增加链接"> 
   &nbsp;   <input type="button" name="button" id="button" value="返回管理" onClick="location.href='?'"></td>
  </tr>
  </form>
</table>
<% end sub

sub modi()
dim rs
set rs=conn.execute("select * from "&predb&"keylink where id="&id)
%>
<table class="tableBorder" cellspacing="1" cellpadding="2" width="96%" align="center" border="0">
<tr>
		<th height="25" colspan="2" align="center">增加站内链接</th>
  </tr>
  <tr>
    <td colspan="2" class="TableRow2"><a href="?act=add">增加站内链接</a>&nbsp; <a href="admin_keylink.asp">站内链接首页</a></td>
  </tr>
  <form name="form1" method="post" action="?act=savemodi&id=<%= id %>">
  <tr>
    <td width="21%" align="center" class="TableRow1"><strong>链接文本：</strong> <font color="#FF0000">*</font></td>
    <td width="79%" class="TableRow1"><input name="linktxt" type="text" id="linktxt" value="<%=rs("linktxt")%>" size="58"></td>
  </tr>
  <tr>
    <td align="center" class="TableRow2"><strong>链接地址：</strong> <font color="#FF0000">*</font></td>
    <td class="TableRow2"><input name="linkurl" type="text" id="linkurl" value="<%=rs("linkurl")%>" size="58"></td>
  </tr>
  <tr>
    <td align="center" class="TableRow1"><strong>替换次数：</strong> <font color="#FF0000">*</font></td>
    <td class="TableRow1"><input name="reNum" type="text" id="reNum" value="<%=rs("renum")%>" size="6">
&nbsp; 0为全部替换 </td>
  </tr>
  <tr>
    <td align="center" class="TableRow2"><strong>优 先 级：</strong> <font color="#FF0000">*</font></td>
    <td class="TableRow2"><input name="pai" type="text" id="pai" value="<%=rs("pai")%>" size="6">
&nbsp; 数值越大优先级越高</td>
  </tr>
  <tr>
    <td align="center" class="TableRow1">&nbsp;</td>
    <td class="TableRow1"><input type="submit" name="button" id="button" value="修改链接">
    &nbsp;   <input type="button" name="button" id="button" value="返回管理" onClick="location.href='?'"></td>
  </tr>
  </form>
</table>
<%
set rs=nothing
end sub
%>
<br>
</body>
</html>
