<!--#include file="QvodCms_Conn.asp"-->
<!--#include file="QvodCms_Check.asp"-->
<%Dim action,link_id,linkname,linkurl,linklogo,linkorderid,linktypeid,linkintro
action=Trim(Request.QueryString("action"))
link_id=QvodCms_CLng(Request.QueryString("link_id"))
linkname=Trim(ReplaceHtml(Request.Form("link_name")))
linkurl=Trim(ReplaceHtml(Request.Form("link_url")))
linklogo=Trim(ReplaceHtml(Request.Form("link_logo")))
linkorderid=QvodCms_CLng(Request.Form("link_orderid"))
linktypeid=QvodCms_CLng(Request.Form("link_typeid"))
linkintro=Trim(Request.Form("link_about"))
Call OpenConn()
%><html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<TITLE>管理页面</TITLE>
<link href="skins/css/jaja_main.css" rel="stylesheet" type="text/css" />
<script language = "javaScript" src = "QvodCms_All.js" type="text/javascript"></script>
<style type="text/css">
.td2 input{color: #555;height:21px;}
.td2 .small{color:#999;border:#DFDFDF 1px solid;}
.td2 sup{color:#FF0000;cursor:pointer;}
</style>
</head>
<body>
<table width="100%" border="0" cellspacing="1" cellpadding="0">
<tr><th colspan=2 background="Skins/images/tdbg.gif" class="title"><a href="?action=add">&nbsp;添加新友链</a> <a href="QvodCms_Link.asp?action=delall" target="frmright" onClick="return confirm('删除后将不能恢复,确定要删除吗?');">删除所有链接</a></th>
</tr>
<tr><td class="td2">
<%If action="add" Then%>
<table width="100%" border="0" align="center" cellpadding="4" cellspacing="1" class="tbtitle" style="background: #f3f9fb;">
  <form method="post" action="?action=saveadd">
    <tr bgcolor="#f5fafe">
      <td width="120" style="text-align:center">友链名称</td>
      <td ><input size=50 type="text" name="link_name" onFocus="if(this.value=='网站名称')this.value='';" value="网站名称"></td>
    </tr>
    <tr bgcolor="#f5fafe">
      <td style="text-align:center">友链地址</td>
      <td><input size=50  type="text" name="link_url"  onfocus="if(this.value=='网站地址')this.value='http://';" value="网站地址" ></td>
    </tr>
    <tr bgcolor="#f5fafe">
      <td style="text-align:center">友链图片</td>
      <td><input size=50  type="text" name="link_logo"  onfocus="this.value='http://';" value="http://www.qvodcms.com/images/logocms.gif"></td>
    </tr>
    <tr bgcolor="#f5fafe">
      <td style="text-align:center">友链方式</td>
      <td><select name='link_typeid'><option value='0'>文字形式</option><option value='1'>图片形式</option></select></td>
    </tr>		
    <tr bgcolor="#f5fafe">
      <td style="text-align:center">友链排序</td>
      <td><input size="9" type="text" name="link_orderid" value="<%=QvodCms_MaxId("link")%>" /></td>
    </tr>
    <tr bgcolor="#f5fafe">
      <td style="text-align:center">友链介绍</td>
      <td><textarea name="link_About" cols="30" rows="5">友链介绍</textarea></td>
    </tr>
    <tr bgcolor="#f5fafe">
      <td colspan="2" style="padding-left:100px;">
        <input type="submit" value="添 加 新 友 链" name="Submit2" />
      </td>
    </tr>
  </form>
</table>
<%
ElseIf action="saveadd" Then
	If linkname="" or linkurl="" Then  Call QvodCms_Err("必要参数不能为空！")
	Conn.Execute(" Insert Into [qvodcms_link] (link_name,link_url,link_logo,link_orderid,link_typeid,link_About) values ('"&linkname&"','"&linkurl&"','"&linklogo&"',"&linkorderid&","&linktypeid&",'"&linkintro&"') ")
	Response.Redirect("?")
ElseIf action="saveedit" Then
	id_a = Split(Request.Form("id"), ", ")
	For Each id In id_a
	Conn.Execute "update [qvodcms_link] Set link_orderid="&QvodCms_CLng(Request.Form("link_orderid_"&id))&",link_typeid="&QvodCms_CLng(Request.Form("link_typeid_"&id))&" where link_id="&id
	Next
	Response.redirect("?")
ElseIf action="saveedit2" Then
	Conn.Execute "update [qvodcms_link] Set link_name='"&linkname&"',link_url='"&linkurl&"',link_logo='"&linklogo&"',link_orderid="&linkorderid&",link_typeid="&linktypeid&",link_About='"&linkintro&"' where link_id="&link_id
	Response.redirect("?????")	
ElseIf action="del" Then
	Conn.Execute(" delete from qvodcms_link where link_id="&link_id&" ")
	Response.redirect("?")
ElseIf action="delall" Then
	Conn.Execute(" delete from qvodcms_link ")
	Response.redirect("?")	
ElseIf action="edit" Then
    Set ers = Conn.Execute(" Select * from qvodcms_link where link_id="&link_id&" ")
	If Not(ers.bof and ers.eof) Then%>
	<table width="100%" border="0" align="center" cellpadding="4" cellspacing="1" class="tbtitle" style="background: #f3f9fb;">
	  <form method="post" action="?action=saveedit2&link_id=<%=link_id%>">
		<tr bgcolor="#f5fafe">
		  <td width="120" style="text-align:center">友链名称</td>
		  <td ><input size=50 type="text" name="link_name" value="<%=ers("link_name")%>"></td>
		</tr>
		<tr bgcolor="#f5fafe">
		  <td style="text-align:center">友链地址</td>
		  <td><input size=50  type="text" name="link_url"  value="<%=ers("link_url")%>"></td>
		</tr>
		<tr bgcolor="#f5fafe">
		  <td style="text-align:center">友链图片</td>
		  <td><input size=50  type="text" name="link_logo"  value="<%=ers("link_logo")%>"></td>
		</tr>
		<tr bgcolor="#f5fafe">
		  <td style="text-align:center">友链方式</td>
		  <td><select name='link_typeid'><option value='0' <%=QvodCms_Select(0,ers("link_typeid"))%>>文字形式</option><option value='1' <%=QvodCms_Select(1,ers("link_typeid"))%>>图片形式</option></select></td>
		</tr>		
		<tr bgcolor="#f5fafe">
		  <td style="text-align:center">友链排序</td>
		  <td><input size="9" type="text" name="link_orderid" value="<%=ers("link_orderid")%>" /></td>
		</tr>
		<tr bgcolor="#f5fafe">
		  <td style="text-align:center">友链介绍</td>
		  <td><textarea name="link_About" cols="30" rows="5"><%=ers("link_About")%></textarea></td>
		</tr>
		<tr bgcolor="#f5fafe">
		  <td colspan="2" style="padding-left:100px;"><input type="submit" value="编 辑 友 链 信 息" name="Submit2" /></td>
		</tr>
	  </form>
	</table>		
<%
    Else
    Call QvodCms_Err("没有查询到相关数据,请返回！")
    End If
	Set ers=nothing
Else%>
<table width="100%" border=0 align=center cellpadding="4" cellspacing=1 class=tbtitle style="background: #f3f9fb;">
<tr bgcolor="#e0eff7" style="text-align:center;">
  <td width="30">选中</td>
  <td width="40">ID</td>
  <td width="120">网站名称</td>  
  <td width="250">网站地址</td>
  <td width="100">网站LOGO</td> 
  <td width="100">友链形式</td> 
  <td width="60">友链排序</td>
  <td style="text-align:left; padding-left:10px;">管理操作</td>
</tr>
<% 	Set rs = Server.CreateObject("adodb.recordset")
	sql = "select * from qvodcms_link order by link_orderid asc"
	rs.Open sql, Conn, 1, 1
	If Not rs.eof Then
	    Response.Write "<form action='?action=saveedit' method='post' name='form'>"&chr(10)
		Do while not rs.eof
		Response.Write "<tr align=""center"" bgcolor=#f5fafe>"&chr(10)
		Response.Write "<td ><input name='id' type='checkbox' value='"&rs("link_id")&"' style='border:none' checked></td>"&chr(10)
		Response.Write "<td >"&rs("link_id")&"</td>"&chr(10)
		Response.Write "<td >"&rs("link_name")&"</td>"&chr(10)
		Response.Write "<td ><a href='"&rs("link_url")&"' target='_blank'>"&rs("link_url")&"</a></td>"&chr(10)
		Response.Write "<td ><a href='"&rs("link_url")&"' target='_blank'><img src='"&rs("link_logo")&"' width='88' height='31' border='0'></a></td>"&chr(10)
		Response.Write "<td ><select name='link_typeid_"&rs("link_id")&"'><option value='0' "&QvodCms_Select(0,rs("link_typeid"))&">文字形式</option><option value='1' "&QvodCms_Select(1,rs("link_typeid"))&">图片形式</option></select></td>"&chr(10)
		Response.Write "<td ><input size=5 type='text' name='link_orderid_"&rs("link_id")&"' value='"&rs("link_orderid")&"'></td>"&chr(10)
		Response.Write "<td style='text-align:left; padding-left:10px;'><a href=?action=edit&link_id="&rs("link_id")&">修改</a>  <a href='?action=del&link_id="&rs("link_id")&"' onClick=""return confirm('删除后将不能恢复,确定要删除吗?');"">删除</a></td>"&chr(10)
		Response.Write "</tr>"&chr(10)	
		rs.movenext
		Loop
		Response.Write "<tr bgcolor='#ffffff'><td colspan='8' align='center'><input type='submit' value='批量修改选中友链' name='Submit'></td></tr>"&chr(10)&"</form>"
	Else 
	    Response.Write("<tr bgcolor=#f5fafe><td colspan='8'>没有友链请先添加!</td></tr>")	
    End If
	rs.Close
	Set rs=nothing
End If
%>
</table>
<%Call CloseConn()%>
</td></tr> 
</table>
</body>
</html>