<!--#include file="../../ACT.Function.asp"-->
<!--#include file="../../../ACT_inc/cls_pageview.asp"-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>友情链接系统管理-By ACTCMS</title>
<link href="../../Images/css1/css.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table">
  <tr>
    <td colspan="2"  class="bg_tr"><strong>您现在的位置：子系统管理 &gt;&gt; <a href="Index.asp">链接系统管理</a> &gt;&gt; 新增友情链接</strong></td>
  </tr>
  <tr>
    <td width="9%" align="right" ><strong>链接选项：</strong></td>
    <td ><strong><a href="?">管理首页</a> ┆ <a href="?Action=Add&classlinkid=<%=request("classlinkid")%>">新增友情链接</a></strong></td>
  </tr>
</table><% 
	Dim ShowErr,Action
	Action = Request("Action")
	If Not ACTCMS.ACTCMS_QXYZ(0,"xqlj_ACT","") Then   Call Actcms.Alert("对不起，你没有操作权限！","") 
	Select Case Action
			Case "Edit","Add"
				Call Edit()
			Case "SaveAdd"
				Call SaveAdd
			Case "SaveEdit"
				Call SaveEdit
			Case "del"
				Call Del()
			Case Else
				Call Main()
	End Select
	
	Sub SaveAdd()
		Dim SiteName,Description,SQL,rs,id
		SiteName = Trim(Request.Form("SiteName"))
		Description = ACTCMS.Rsql(Request.Form("Description"))
		IF 	SiteName = "" Then 
			ShowErr = "<li>网站名称名称不能为空!</li>"
			Response.Redirect("../../Error.asp?Errs="&Server.URLEncode(ShowErr)&"&ErrorUrl="&"&Title=1")
			Response.End
		End IF
		SQL = "Select * From Link_Act "
		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")=ACTCMS.ChkNumeric(request("ClassLinkID"))
		  Rs("locked")=ACTCMS.ChkNumeric(request("locked"))
		  Rs("rec")=ACTCMS.ChkNumeric(request("rec"))
		  Rs("LinkType")=ACTCMS.ChkNumeric(request("LinkType"))
		  Rs("sh")=1	
		  Rs("Logo")=request("Logo")
		Rs.update
		Rs.Close:Set Rs=Nothing
		ShowErr = "<li>添加新链接成功!&nbsp;&nbsp;<a href='sys_act/link/Index.asp'><b>返回友情链接管理</b></a></li>"
		Response.Redirect("../../Error.asp?Errs="&Server.URLEncode(ShowErr)&"&ErrorUrl=")
		Response.End
	End Sub	
		
	Sub SaveEdit()
		Dim SiteName,Description,SQL,rs,id
		SiteName = Trim(Request.Form("SiteName"))
		Description = ACTCMS.Rsql(Request.Form("Description"))
		ID = ACTCMS.ChkNumeric(Request("ID"))
		IF 	SiteName = "" Then 
			ShowErr = "<li>网站名称不能为空!</li>"
			Response.Redirect("../../Error.asp?Errs="&Server.URLEncode(ShowErr)&"&ErrorUrl="&"&Title=1")
			Response.End
		End IF
		SQL = "Select * From Link_Act 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")=ACTCMS.ChkNumeric(request("classlinkID"))
		  Rs("locked")=ACTCMS.ChkNumeric(request("locked"))
		  Rs("rec")=ACTCMS.ChkNumeric(request("rec"))
		  Rs("LinkType")=ACTCMS.ChkNumeric(request("LinkType"))
		  Rs("Logo")=request("Logo")
			Rs.update
		Else
			ShowErr = "<li>无此链接，参数传递出错</li>"
			Response.Redirect("../../Error.asp?Errs="&Server.URLEncode(ShowErr)&"&ErrorUrl="&"&Title=1")
			Response.End
		End IF
		Rs.Close:Set Rs=Nothing
		ShowErr = "<li>链接修改成功!&nbsp;&nbsp;<a href='sys_act/link/Link_Act.asp'><b>返回友情链接管理</b></a></li>"
		Response.Redirect("../../Error.asp?Errs="&Server.URLEncode(ShowErr)&"&ErrorUrl=")
		Response.End
	End Sub	
	Sub Del()
		Conn.Execute ("Delete from Link_Act Where ID=" & ACTCMS.ChkNumeric(Request.QueryString("ID")))		
		Set conn=nothing
		ShowErr = "<li>链接删除成功！</li>"
		Response.Redirect("../../Error.asp?Errs="&Server.URLEncode(ShowErr)&"&ErrorUrl=sys_act/link/Link_Act.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 arrRecordInfo, i
	Dim sql, sqlCount,pages,Sqls
	pages = "action="&Request("action")&"&page"
	Select Case Request.QueryString("Action")
		Case "List"
			Sqls = " where sh=1 and classlinkid="&Request.QueryString("classlinkid")&"  "
			pages = "Action=List&classlinkid="&Request("classlinkid")&"&page"
		Case Else
			Sqls = " where sh=1 "
			pages = "page"
	End Select

	sql = "SELECT [ID], [ClassLinkID], [SiteName], [LinkType],  [AddDate], [Rec], [Locked]" & _
		" FROM [Link_Act]" &Sqls& _
		"ORDER BY [ID] deSC"
	sqlCount = "SELECT Count([ID]) " & _
			" FROM [Link_Act]"&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		
		arrRecordInfo = clsRecordInfo.arrRecordInfo
		strPageInfo = clsRecordInfo.strPageInfo
		Set clsRecordInfo = nothing
 %>
  <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table">
    <tr>
      <td width="200" align="center" ><STRONG>网站名称</STRONG></td>
      <td width="138" align="center" ><strong>所属类别</strong></td>
      <td width="120" align="center" ><strong>类型</strong></td>
      <td width="204" align="center" ><strong>添加日期</strong></td>
      <td width="113" align="center" ><strong>推荐站点</strong></td>
      <td width="88" align="center" ><strong>锁定</strong></td>
      <td width="120" align="center" ><strong>管理</strong></td>
    </tr>
	 <%
		Dim bgColor
		If IsArray(arrRecordInfo) Then
			For i = 0 to UBound(arrRecordInfo, 2)
	%>
    <tr onMouseOver=overColor(this) onMouseOut=outColor(this)>
      <td align="center"  >
	    <a href="?Action=Edit&ID=<%=arrRecordInfo(0,i)  %>">
	  <%=arrRecordInfo(2,i)%></a></td>
      <td align="center"  ><%
	  			Dim Rs ,ClassLinkName
			  Set Rs = server.CreateObject("adodb.recordset")
					Rs.Open "select id,ClassLinkName from ClassLink_Act where ID="& arrRecordInfo(1,i) &"",Conn,1,1
					if  Not Rs.bof then
							ClassLinkName =Rs("ClassLinkName")
					Else
							ClassLinkName ="<font color=red>意外错误</font>"
					End if 
				  response.Write ClassLinkName
	   %></td>
      <td align="center"  >
	  <%if arrRecordInfo(3,i) =0 then response.Write "文字链接" else response.Write "图片链接" %></td>
      <td align="center"  ><%=arrRecordInfo(5,i)  %></td>
      <td align="center"  ><%if arrRecordInfo(6,i) =0 then response.Write "<font color=green>是</font>" else response.Write "<font color=red>否</font>" %></td>
      <td  align="center" >
	  <%if arrRecordInfo(6,i) =0 then response.Write "<font color=green>正常</font>" else response.Write "<font color=red>锁定</font>" %></td>
      <td  align="center" ><a href="?Action=Edit&ID=<%=arrRecordInfo(0,i)  %>">修改</a>┆ <a href="?Action=del&ID=<%= arrRecordInfo(0,i) %>" onClick="return confirm('确认删除此链接吗?')">删除</a></td>
    </tr>
	<% 
	Next
	End If
	%>
    
    <tr >
      <td height="25" colspan="20" align="center" ><%= strPageInfo%></td>
    </tr>
  </table>

<script language="javascript">
function SelectIterm(form,sign){
	for (var i=0; i<form.elements.length;i++ ){
		if (form.elements[i].type == "checkbox"){
				var e=form.elements[i];
					if (sign==0) e.checked= true;
					if (sign==1) e.checked= !e.checked;
					if (sign==2) e.checked= false;
		}
	} 
}
function overColor(Obj)
{
	var elements=Obj.childNodes;
	for(var i=0;i<elements.length;i++)
	{
		elements[i].className="tdbg1"
		Obj.bgColor="";
	}
	
}
function outColor(Obj)
{
	var elements=Obj.childNodes;
	for(var i=0;i<elements.length;i++)
	{
		elements[i].className="tdbg";
		Obj.bgColor="";
	}
}
</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 = ACTCMS.ChkNumeric(Request("ID"))
		IF ID = 0 Then Response.Write "请指定要修改的链接":Response.End
		Set Rs=Conn.Execute("Select * from Link_Act Where ID=" & ID)
			if Rs.Bof And Rs.EOF then
				 Response.Write "不存在此链接！"
				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
  %>
  <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table">
 <form name="form1" method="post" action="?">  <tr>
      <td width="13%" align="right"  ><strong>网站名称：</strong></td>
      <td width="80%"  ><input name="SiteName" type="text" id="SiteName" value="<%= SiteName %>" size="40"></td>
    </tr>
    <tr>
      <td align="right"  ><strong>所属类别：</strong></td>
      <td  ><select Name="ClassLinkID" class=""textbox""><% 	
					Dim LinkRs
					Set LinkRs = Conn.Execute("Select id,ClassLinkName From ClassLink_Act")
					 Do While Not LinkRs.EOF
					   If CStr(classlinkID) = CStr(LinkRs(0)) Then
						response.Write ("<Option value=" & LinkRs(0) & " selected>" & LinkRs(1) & "</OPTION>")
					   Else
						response.Write ("<Option value=" & LinkRs(0) & ">" & LinkRs(1) & "</OPTION>")
					   End If
					   LinkRs.MoveNext
					 Loop
					 LinkRs.Close
					 Set LinkRs = Nothing
				   
		             %> </Select></td>
    </tr>
    <tr>
      <td align="right"  ><strong>网站站长：</strong></td>
      <td  ><input name="Webadmin" type="text" id="Webadmin" value="<%= Webadmin %>" size="40"></td>
    </tr>
    <tr>
      <td align="right"  ><strong>站长信箱：</strong></td>
      <td  ><input name="Email" type="text" id="Email" value="<%= Email %>" size="40"></td>
    </tr>
    <tr>
      <td align="right"  ><strong>是否锁定：</strong></td>
      <td  ><input  <% IF locked = 0 Then Response.Write "Checked" %> type="radio" id="locked1" name="locked" value="0"><label for="locked1">正常</label>
        <input  <% IF locked = 1 Then Response.Write "Checked" %> type="radio" id="locked2" name="locked" value="1"><label for="locked2">锁定</label>        </td>
    </tr>
    <tr>
      <td align="right"  ><strong>网站地址：</strong></td>
      <td  ><input name="Url" type="text" id="Url" value="<%= Url %>" size="40"></td>
    </tr>
    <tr>
      <td align="right"  ><strong>链接类型：</strong></td>
      <td  >
	  <input  <% IF LinkType = 0 Then Response.Write "Checked" %> type="radio" id="radio3" name="LinkType" value="0">
        <label for="radio3">文字链接</label>
        <input  <% IF LinkType = 1 Then Response.Write "Checked" %> type="radio" id="radio4" name="LinkType" value="1">
        <label for="radio4">图片链接</label></td>
    </tr>
    <tr>
      <td align="right"  ><strong>Logo地址：</strong></td>
      <td  ><input name="Logo" type="text" id="Logo" value="<%= Logo %>" size="40"></td>
    </tr>
    <tr>
      <td align="right"  ><strong>推荐站点：</strong></td>
      <td  ><input  <% IF rec = 0 Then Response.Write "Checked" %> type="radio" id="radio" name="rec" value="0"><label for="radio">是</label>
       
        <input  <% IF rec = 1 Then Response.Write "Checked" %> type="radio" id="radio2" name="rec" value="1"><label for="radio2">否</label>        </td>
    </tr>
	<%If request("Action")="Edit" Then %>
    <tr>
      <td align="right"  ><strong>添加日期：</strong></td>
      <td  ><input name="AddDate" type="text" id="AddDate" value="<%= AddDate %>" size="40" onfocus="WdatePicker()"  ></td>
    </tr>
	<%End If %>
    <tr>
      <td align="right"  ><strong>网站简介：</strong></td>
      <td  ><textarea name="Description" cols="50" rows="8" id="Description"><%= Description %></textarea></td>
    </tr>
    <tr>
      <td align="right"  >&nbsp;</td>
      <td  >
	  <input name="ID" type="hidden" value="<%=request("ID")%>">
	  <input name="Action" type="hidden" id="Action" value="Save<%=frmAction%>">
	<input type="submit"  onclick=CheckInfo()  class="act_btn" name="Submit" value=" 保 存 "> 
	  <input type="reset" class="act_btn"  name="Submit2" value=" 取 消 " /></td>
    </tr>
  </table>
</form>
<SCRIPT language=javascript>
		function CheckInfo()
		{
		  if(document.form1.SiteName.value=="")
			{
			  form1.Submit.disabled=true;	
			  form1.Submit2.disabled=true;	
			  alert("网站名称不能为空！");
			  document.form1.ClassLinkName.focus();
			  form1.Submit.disabled=false;	
			  form1.Submit2.disabled=false;	
			  return false;
			}
		form1.Submit.value="正在提交数据,请稍等...";
		form1.Submit.disabled=true;	
		form1.Submit2.disabled=true;	
	    form1.submit();
        return true;
		}
		</script>
<%
 
 end sub
 CloseConn %>
<br>
<br> </body>
</html>
