<!--#include file="../../fy.Function.asp"-->
<!--#include file="../../../fy_inc/cls_pageview.asp"-->
<!--#include file="../../../editor/index.asp"-->
<!doctype html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>友情链接系统管理-By fycms</title>
<link rel="stylesheet" type="text/css" href="../../css/base.css">
<link rel="stylesheet" type="text/css" href="../../css/content.css">
<script type="text/javascript" src="../../../fy_inc/js/jquery.js"></script>
<script type='text/javascript' src='../../../fy_inc/js/lhg/lhgdialog.min.js'></script>
<script type='text/javascript' src='../../js/main.js'></script>
</head>
<body>

<div class="content"> 
	<div class="breadnav">当前位置：<a href="#">后台首页</a> >> 链接系统管理</div>
    <div class="opers">
		<a href="index.asp?" class="btn <%If request("Action")="" Then echo " btn_primary" %>">管理首页</a>
		<a href="index.asp?Action=Add" class="btn">新增友情类别</a>
		<a href="Linksh_fy.asp" class="btn">链接审核</a>
		 <a href="?Action=Add&classlinkid=<%=request("classlinkid")%>" class="btn <%If request("Action")="Add" Or  request("Action")="Edit" Then echo " btn_primary" %>">新增/修改 友情链接</a>
    </div><% 
	Dim ShowErr,Action
	Action = Request("Action")
	If Not fycms.fycms_QXYZ(0,"yqlj_fy","") Then   Call fycms.Alert("对不起，你没有操作权限！","") 
	Select Case Action
			Case "Edit","Add"
				Call Edit()
			Case "SaveAdd"
				Call SaveAdd
			Case "SaveEdit"
				Call SaveEdit
			case "sh"
				call sh()
			Case "del"
				Call Del()
			Case Else
				Call Main()
	End Select
	
	Sub sh()
		Dim ID:ID =Request("ID")
		IF ID = "" Then
 			Call fycms.ActErr("请先选定链接","","")
 			Response.End
		End IF		
		
			Conn.execute("Update Link_fy set sh=1 where ID in ("&ID&")")
			set conn=nothing
			 Call fycms.ActErr("链接审核成功","sys_fy/link/Linksh_fy.asp","")
 	End Sub
	Sub SaveAdd()
		Dim SiteName,Description,SQL,rs,id
		SiteName = Trim(Request.Form("SiteName"))
		Description = RSQL(Request.Form("Description"))
		If ChkNumeric(request("classlinkID"))=0 Then Call fycms.ActErr("所属类别不能为空","","")

		IF 	SiteName = "" Then 
  			Call fycms.ActErr("网站名称名称不能为空","","")
 			Response.End
		End IF
		SQL = "Select * From Link_fy "
		Set Rs=Server.CreateObject("Adodb.RecordSet")
		Rs.Open SQL,Conn,1,3
		Rs.addnew
		 Rs("SiteName") = SiteName
		  Rs("Description")=request("Description")
		  Rs("Webadmin")=request("Webadmin")
		  Rs("Email")=request("Email")
		  Rs("url")=request("url")
		  Rs("AddDate")=now
		  Rs("classlinkID")=ChkNumeric(request("ClassLinkID"))
		  Rs("locked")=ChkNumeric(request("locked"))
		  Rs("rec")=ChkNumeric(request("rec"))
		  Rs("LinkType")=ChkNumeric(request("LinkType"))
		  Rs("sh")=1	
		  Rs("Logo")=request("Logo")
		Rs.update
		Rs.Close:Set Rs=Nothing
 		 Call fycms.ActErr("添加新链接成功","sys_fy/link/Index.asp","")
		Response.End
	End Sub	
		
	Sub SaveEdit()
		Dim SiteName,Description,SQL,rs,id
		SiteName = Trim(Request.Form("SiteName"))
		Description = RSQL(Request.Form("Description"))
		ID = ChkNumeric(Request("ID"))
		IF 	SiteName = "" Then 
 			Call fycms.ActErr("网站名称不能为空","","")
 			Response.End
		End IF
		SQL = "Select * From Link_fy Where ID="&ID
		Set Rs=Server.CreateObject("Adodb.RecordSet")
		Rs.Open SQL,Conn,1,3
		IF Not (Rs.Eof And Rs.Bof) Then
		 Rs("SiteName") = SiteName
		Rs("Description")=request("Description")
		  Rs("Webadmin")=request("Webadmin")
		  Rs("Email")=request("Email")
		  Rs("url")=request("url")
		  Rs("classlinkID")=ChkNumeric(request("classlinkID"))
		  Rs("locked")=ChkNumeric(request("locked"))
		  Rs("rec")=ChkNumeric(request("rec"))
		  Rs("LinkType")=ChkNumeric(request("LinkType"))
		  Rs("Logo")=request("Logo")
			Rs.update
		Else
			Call fycms.ActErr("无此链接，参数传递出错","","")
 			Response.End
		End IF
		Rs.Close:Set Rs=Nothing
 		Call fycms.ActErr("链接修改成功","sys_fy/link/Link_fy.asp","")
 		Response.End
	End Sub	
	Sub Del()
		Conn.Execute ("Delete from Link_fy Where ID=" & ChkNumeric(Request.QueryString("ID")))		
		Set conn=nothing
 		Call fycms.ActErr("链接删除成功","sys_fy/link/Link_fy.asp","")
  		Response.End
    End Sub
		
 Sub Main
	Dim strLocalUrl
	strLocalUrl = request.ServerVariables("SCRIPT_NAME")
	Dim intPageNow
	intPageNow = request.QueryString("page")
	Dim intPageSize, strPageInfo
	intPageSize = 30
	Dim arrinfo, i
	Dim sql, sqlCount,pages,Sqls
	pages = "action="&Request("action")&"&page"
	Select Case Request.QueryString("Action")
		Case "List"
			Sqls = " where sh=0 and classlinkid="&Request.QueryString("classlinkid")&"  "
			pages = "Action=List&classlinkid="&Request("classlinkid")&"&page"
		Case Else
			Sqls = " where sh=0 "
			pages = "page"
	End Select

	sql = "SELECT [ID], [ClassLinkID], [SiteName], [LinkType],  [AddDate], [Rec], [Locked]" & _
		" FROM [Link_fy]" &Sqls& _
		"ORDER BY [ID] deSC"
	sqlCount = "SELECT Count([ID]) " & _
			" FROM [Link_fy]"&Sqls
		Dim clsRecordInfo
		Set clsRecordInfo = New Cls_PageView
			clsRecordInfo.intRecordCount = 2816
			clsRecordInfo.strSqlCount = sqlCount
			clsRecordInfo.strSql = sql
			clsRecordInfo.intPageSize = intPageSize
			clsRecordInfo.intPageNow = intPageNow
			clsRecordInfo.strPageUrl = strLocalUrl
			clsRecordInfo.strPageVar = "page"
		clsRecordInfo.objConn = Conn		
		arrinfo = clsRecordInfo.arrinfo
		strPageInfo = clsRecordInfo.strPageInfo
		Set clsRecordInfo = nothing
 %>  <form name="form1" method="post" action="?Action=sh"> 
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <thead>
      <tr>
      <th>ID</th>
      <th>网站名称</th>
	  <th>所属类别</th>
	  <th>类型</th>
	  <th>添加日期</th>
	  <th>推荐站点</th>
	  <th>锁定</th>
	  <th>管理</th>
	  </tr>
    </thead>



	 <%
		Dim bgColor
		If IsArray(arrinfo) Then
			For i = 0 to UBound(arrinfo, 2)
	%>
    <tr>

      <td><input name="ID" type="checkbox" id="ID" value="<%= arrinfo(0,i) %>"></td>


      <td>
	    <a href="?Action=Edit&ID=<%=arrinfo(0,i)  %>">
	  <%=arrinfo(2,i)%></a></td>
      <td><%
	  			Dim Rs ,ClassLinkName
			  Set Rs = server.CreateObject("adodb.recordset")
					Rs.Open "select id,ClassLinkName from ClassLink_fy where ID="& arrinfo(1,i) &"",Conn,1,1
					if  Not Rs.bof then
							ClassLinkName =Rs("ClassLinkName")
					Else
							ClassLinkName ="<font color=red>意外错误</font>"
					End if 
				  echo ClassLinkName
	   %></td>
      <td>
	  <%if arrinfo(3,i) =0 then echo "文字链接" else echo "图片链接" %></td>
      <td><%=arrinfo(5,i)  %></td>
      <td><%if arrinfo(6,i) =0 then echo "是" else echo "<font color=red>否</font>" %></td>
      <td  >
	  <%if arrinfo(6,i) =0 then echo "<font color=green>正常</font>" else echo "<font color=red>锁定</font>" %></td>
      <td><a href="?Action=Edit&ID=<%=arrinfo(0,i)  %>">修改</a>┆ <a href="?Action=del&ID=<%= arrinfo(0,i) %>" onClick="return confirm('确认删除此链接吗?')">删除</a></td>
    </tr>
	<% 
	Next
	End If
	%>
    
    <tr >
      <td height="25" colspan="20" align="center" ><input id="chk" type="checkbox" name="chkall" value="checkbox" onClick="CheckAll(this.form)">
<label for="chk">选择全部</label> <input type=button onclick=CheckForm()  class="btn btn_primary" name=Submit1 value=" 批量审核 " />
 <input type=button onclick=delpost()  class="btn btn_primary" name=Submit1 value=" 批量删除 " />
</td>
    </tr>
  </table></form> 
    <div class="pagelist">
		<%= strPageInfo%>
   </div>
<script language="javascript">

function delpost(){
    document.form1.method="post";
    document.form1.action="?Action=del";
{
	if(confirm('确认要删除吗?此操作不可恢复!')){
	this.document.form1.submit();
	return true;}return false;
}
	}


function CheckAll(form)  
  {  
 for (var i=0;i<form.elements.length;i++)  
    {  
    var e = form1.elements[i];  
   if (e.name != 'chkall')  
      e.checked = form1.chkall.checked;  
   }  
  }
  
function CheckForm()
{ var form=document.form1;
  
 
	    form.submit();
        return true;
	}

</script><% 
 End Sub
sub edit()
dim sitename

	Dim ID,Rs,Description,frmAction
	dim Webadmin,Email,url,AddDate,classlinkID,locked,rec,LinkType,Logo
	IF Action = "Edit" Then
		ID = ChkNumeric(Request("ID"))
		IF ID = 0 Then echo "请指定要修改的链接":Response.End
		Set Rs=Conn.Execute("Select * from Link_fy Where ID=" & ID)
			if Rs.Bof And Rs.EOF then
				 echo "不存在此链接！"
				Exit Sub
			End IF	
			SiteName = Rs("SiteName")
		Description = Rs("Description")
		Webadmin = Rs("Webadmin")
		Email = Rs("Email")
		url = Rs("url")
		AddDate = Rs("AddDate")
		classlinkID = Rs("classlinkID")
		locked = Rs("locked")
		rec = Rs("rec")
		LinkType = Rs("LinkType")
		Logo = Rs("Logo")
		frmAction		= "Edit"
	Else
		Description = ""
		frmAction		= "Add"
		classlinkID = request("classlinkID")
	End IF
  %>


 <form name="form1" method="post" action="?">
 <div class="divtable"> 
        <dl>
            <dt>网站名称：</dt>
            <dd>
             <input name="SiteName" type="text" class="Ainput" id="SiteName" value="<%= SiteName %>" size="40">    
            </dd>
         </dl>
        
        <dl>
            <dt>所属类别：</dt>
            <dd>
               <select Name="ClassLinkID" class="textbox"><% 	
					Dim LinkRs
					Set LinkRs = Conn.Execute("Select id,ClassLinkName From ClassLink_fy")
					 Do While Not LinkRs.EOF
					   If CStr(classlinkID) = CStr(LinkRs(0)) Then
						echo ("<Option value=" & LinkRs(0) & " selected>" & LinkRs(1) & "</OPTION>")
					   Else
						echo ("<Option value=" & LinkRs(0) & ">" & LinkRs(1) & "</OPTION>")
					   End If
					   LinkRs.MoveNext
					 Loop
					 LinkRs.Close
					 Set LinkRs = Nothing
				   
		             %> </Select>
             </dd>
         </dl>
        <dl>
            <dt>网站站长：</dt>
            <dd>
               <input name="Webadmin" type="text" class="Ainput" id="Webadmin" value="<%= Webadmin %>" size="40">
             </dd>
         </dl>
        <dl>
            <dt>站长信箱：</dt>
            <dd>
               <input name="Email" type="text" class="Ainput" id="Email" value="<%= Email %>" size="40">
             </dd>
         </dl>
        <dl>
            <dt>是否锁定：</dt>
            <dd>
               <input  <% IF locked = 0 Then echo "Checked" %> type="radio" id="locked1" name="locked" value="0"><label for="locked1">正常</label>
        <input  <% IF locked = 1 Then echo "Checked" %> type="radio" id="locked2" name="locked" value="1"><label for="locked2">锁定</label>
             </dd>
         </dl>
        <dl>
            <dt>网站地址：</dt>
            <dd>
               <input name="Url" type="text" class="Ainput" id="Url" value="<%= Url %>" size="40">
             </dd>
         </dl>
        <dl>
            <dt>链接类型：</dt>
            <dd>
                <input  <% IF LinkType = 0 Then echo "Checked" %> type="radio" id="radio3" name="LinkType" value="0">
        <label for="radio3">文字链接</label>
        <input  <% IF LinkType = 1 Then echo "Checked" %> type="radio" id="radio4" name="LinkType" value="1">
        <label for="radio4">图片链接</label>
             </dd>
         </dl>
        <dl>
            <dt>Logo地址：</dt>
            <dd>
               <input name="Logo" type="text" class="Ainput" id="Logo" value="<%= Logo %>" size="50">
	  
	     <input id="PicUrls" class="btn btn_primary" onClick="javascript:tdialog(999,'<%=fycms.actsys&fycms.adminurl%>/include/Upload_Admin.asp?A=add&instr=0&ModeID=999&instrname=Logo');" name="button" type="button"   value="点击上传图片">
 
             </dd>
         </dl>
        <dl>
            <dt>推荐站点：</dt>
            <dd>
               <input  <% IF rec = 0 Then echo "Checked" %> type="radio" id="radio" name="rec" value="0"><label for="radio">是</label>
       
        <input  <% IF rec = 1 Then echo "Checked" %> type="radio" id="radio2" name="rec" value="1"><label for="radio2">否</label> 
             </dd>
         </dl>
		 <%If request("Action")="Edit" Then %>
        <dl>
            <dt>网站简介：</dt>
            <dd>
               <textarea name="Description" cols="50" rows="8" id="Description"><%= Description %></textarea>
             </dd>
         </dl>
		 <%End If %>
 
            <dl>
            <dt class="vhid">提交：</dt>
            <dd>
			<input name="ID" type="hidden" value="<%=request("ID")%>">
	  <input name="Action" type="hidden" id="Action" value="Save<%=frmAction%>">
	<input type="submit"  onclick=CheckInfo()  class="btn btn_primary" name="Submit" value=" 保 存 "> 
	  <input type="reset" class="btn"  name="Submit2" value=" 取 消 " />

 
            </dd>
         </dl>
        
    </div>
    </form>



<SCRIPT language=javascript>
		function CheckInfo()
		{
		  if(document.form1.SiteName.value=="")
			{
			  
			  alert("网站名称不能为空！");
			  document.form1.ClassLinkName.focus();
		 
			  return false;
			}
	 
	    form1.submit();
        return true;
		}
		</script>
<%
 
 end sub
 CloseConn %>
</div> </body>
</html>
