<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="Conn.asp"-->
<!--#include file="Ex_Cls/Ex_SkinCls.asp"-->
<!--#include file="Ex_Cls/Ex_SplitPageCls.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<script src="inc/main.js"></script>
</head>
<link href="Admin_STYLE.CSS" rel="stylesheet" type="text/css"> 
<body leftmargin="2" topmargin="0" marginwidth="0" marginheight="0" class="bgcolor">
<%Dim ExComm
Set ExComm=new Ex_CommonCls
ExComm.IsAdLogin 
ExComm.IsIpAllow
dim action
 action=request.querystring("action")
 select case action
 case "show"
 call show()
 case "change"
 call change()
 Case "del"
 Call del()
 Case "addf"
 Call AddF()
 Case "add"
 Call Add()
 Case "clsadd"
	clsadd
 Case "clschange"
	ClsChange
 Case "clsdel"
	ClsDel
 Case "clsaddf"
 	ClsAddF
 Case "clsshow"
	ClsShow
 end select
 sub show()
    Dim ExPages,page,Rs
    Set ExPages=new Ex_SplitPageCls
    Expages.letConn=Conn
    Expages.letColumns="select * "
    ExPages.letDataFrom="from Ex_Links"
	ExPages.letOrder="order by id desc"
	set rs=server.createobject("adodb.recordset")
		Expages.letPageSize="15"
	If ExComm.G(request("page"))="" Then
		page=1
	Else
		page=ExComm.G(request("page"))
	End If
	Expages.letStrPage="&action=show"
	ExPages.letPage=CInt(page)
	ExPages.Execute()
	%>
	<form name="form1" method="post" action="?action=change">
  <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#FFFFFF" class="border">
    <tr>
      <th class="topbg" colspan="6">友情连接管理</th>
    </tr>
    <tr>
      <td class="tdbg" width="16%" height="21"><div align="center">网站名称</div></td>
      <td class="tdbg" width="19%"><div align="center">网站地址</div></td>
      <td class="tdbg" width="21%"><div align="center">logo地址</div></td>
      <td class="tdbg" width="16%"><div align="center">所属分类</div></td>
      <td class="tdbg" width="17%"><div align="center">验证</div></td>
      <td class="tdbg" width="11%"><div align="center">操作</div></td>
    </tr>
	<%
	Set Rs=Expages.GetRs
	If Expages.GetRsCount<>0 Then
		Do While Not rs.eof
	%>
    <tr>
      <td class="tdbg"><input name="linkname<%=rs("id")%>" type="text" id="linkname<%=rs("id")%>" value="<%=rs("linkname")%>"></td>
      <td class="tdbg"><div align="center">
        <input name="linkurl<%=rs("id")%>" type="text" id="linkurl<%=rs("id")%>" value="<%=rs("linkurl")%>">
      </div></td>
      <td class="tdbg"><input name="linklogo<%=rs("id")%>" type="text" id="linklogo<%=rs("id")%>" value="<%=rs("linklogo")%>"></td>
      <td class="tdbg"><div align="center">
	  	<select name="cls<%=rs("id")%>" id="cls<%=rs("id")%>">
	  <%=ExComm.GetLinksClassSelectCache(rs("parentid"))%>
      </select>
	  </div></td>
      <td class="tdbg"><div align="center">
        <input type="hidden" name="ids" id="ids" value="<%=rs("id")%>">
        <input name="isshow<%=rs("id")%>" type="checkbox" id="isshow<%=rs("id")%>" value="true" <%if rs("isshow")=true then%>checked<%end if%>>
      </div></td>
      <td class="tdbg"><div align="center"><a href="?action=del&id=<%=rs("id")%>" onClick="return confirm('是否删除?')">删除</a></div></td>
    </tr>
	<%
	 rs.movenext
	 Loop
	 End If
	%>
    <tr>
      <td class="tdbg" colspan="7"><div align="center">
	  <%=Expages.Show%>
        <input type="submit" name="Submit" value="提交">
      </div></td>
    </tr>
  </table>
  如果想删除logo地址请用<font color=red> 无</font>代替Logo地址 
    </form>
<%end sub
sub AddF()
%>
<script>
function CheckLinkAdd()
{	
	var n=document.getElementById("linkname");
	var u=document.getElementById("linkurl");
	var logo=g("linklogo").value;
	var c=document.getElementById("cls");
	if (n.value=="")
	{
		alert("网站名称不能为空哦");
		n.focus();
		return false;
	}
	if (u.value=="" || u.value.indexOf("http://")==-1)
	{
		alert("网站地址不能为空,并且必须以http://开头");
		u.focus();
		return false;
	}
	if (logo!="" && logo.indexOf("http://")==-1)
	{
		return msg("logo地址必须以http://开头","linklogo");
	}
	if (c.value=="")
	{
		alert("网站分类连接不能为空哦");
		c.focus();
		return false;
	}

}
</script>
<form name="form1" method="post" action="?action=add" onSubmit="return CheckLinkAdd()">
  <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#FFFFFF" class="border">
    <tr>
      <th class="topbg" colspan="5">友情连接添加</th>
    </tr>
    <tr>
      <td class="tdbg" width="21%" height="21"><div align="center">网站名称</div></td>
      <td class="tdbg" width="26%"><div align="center">网站地址</div></td>
      <td width="19%" class="tdbg"><div align="center">logo地址</div>        <div align="center"></div></td>
      <td class="tdbg" width="17%"><div align="center">所属分类</div></td>
      <td class="tdbg" width="17%"><div align="center">操作</div></td>
    </tr>
    <tr>
      <td class="tdbg"><div align="center">
        <input name="linkname" type="text" id="linkname">
      </div></td>
      <td class="tdbg"><div align="center">
        <input name="linkurl" type="text" id="linkurl" size="30" value="http://">
      </div></td>
      <td class="tdbg"><div align="center">
        <input name="linklogo" type="text" id="linklogo" size="30">        
      </div>
      <div align="center"></div></td>
      <td class="tdbg">
	    <div align="center">
	      <select name="cls" id="cls">
	        <%=ExComm.GetLinksClassSelectCache(0)%>
            </select>
        </div></td>
      <td class="tdbg"><div align="center">
        <input type="submit" name="Submit22" value="添加">
      </div></td>
    </tr>
    <tr>
      <td class="tdbg" colspan="6">&nbsp;</td>
    </tr>
  </table>
</form>
<%
end sub 
sub ClsAddF
%>
	<script>
	function CheckClsAdd()
	{
		var n=document.getElementById("clsname");
		var o=document.getElementById("clsorder");
		if (n.value=="")
		{
			alert("分类名称不能为空");
			n.focus();
			return false;
		}
		if (!isNumber(o.value))
		{
			alert("分类序号应该为数字");
			o.focus();
			return false;
		}
	}
	</script>
	<form name="form1" method="post" action="?action=clsadd" onSubmit="return CheckClsAdd()">
  <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#FFFFFF" class="border">
    <tr>
      <th class="topbg" colspan="5">友情连接分类添加</th>
    </tr>
    <tr>
      <td width="23%" class="tdbg"><div align="center">分类名称：
      </div>
      <div align="center"></div></td>
      <td width="31%" class="tdbg"><div align="center">
        <input name="clsname" type="text" id="clsname" size="25">
      </div></td>
      <td width="17%" class="tdbg"><div align="center">分类序号</div>
      <div align="center"></div></td>
      <td width="18%" class="tdbg"><input name="clsorder" type="text" id="clsorder" size="25"></td>
      <td width="11%" class="tdbg"><div align="center">
        <input type="submit" name="Submit2" value="添加">
      </div></td>
    </tr>
    <tr>
      <td class="tdbg" colspan="6">&nbsp;</td>
    </tr>
  </table>
    </form>
<%
end sub 
Sub clsadd
	Dim clsname,clsorder,sql
	clsname=ExComm.F(Request.Form("clsname"))
	clsorder=Request.Form("clsorder")
	Sql="insert into Ex_LinksCls (clsname,orderx) values('"&clsname&"',"&clsorder&")"
	Conn.Execute Sql
	ExComm.ClearCache(sn)
	ExComm.ShowMsg "友情连接分类添加成功",Request.Servervariables("http_referer")
End Sub 
sub ClsShow
	Dim Rs
	Set Rs=Conn.Execute("select * from Ex_LinksCls order by orderx asc")
%>
	<form name="form1" method="post" action="?action=clschange">
  <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#FFFFFF" class="border">
    <tr>
      <th class="topbg" colspan="5">友情连接分类管理</th>
    </tr>
	<%
		Do While Not Rs.eof 
	%>
    <tr>
      <td width="23%" class="tdbg"><div align="center">分类名称：
      </div>
      <div align="center"></div></td>
      <td width="31%" class="tdbg"><div align="center">
        <input name="clsname<%=Rs("id")%>" type="text" id="clsname<%=Rs("id")%>" size="25" value="<%=Rs("clsname")%>">
      </div></td><input type="hidden" id="ids" name="ids" value="<%=Rs("id")%>">
      <td width="17%" class="tdbg"><div align="center">分类序号</div>
      <div align="center"></div></td>
      <td width="18%" class="tdbg"><input name="clsorder<%=Rs("id")%>" type="text" id="clsorder<%=Rs("id")%>" size="25" value="<%=Rs("orderx")%>"></td>
      <td width="11%" class="tdbg"><div align="center"><a href="?action=clsdel&id=<%=Rs("id")%>" onClick="return confirm('是否要删除分类？删除后此分类下的所有连接将被删除。')">删除</a></div></td>
    </tr>
	<%
			Rs.movenext
	    Loop 
	%>
    <tr>
      <td class="tdbg" colspan="6"><div align="center">
        <input type="submit" name="Submit3" value="提交">
      </div></td>
    </tr>
  </table>
    </form>
<%
end sub 
Sub ClsChange
	Dim ids,clsname,orderx,i,Sql
	ids=Request.Form("ids")
	ids=Split(ids,",")
	For i=0 To UBound(ids)
		clsname=Request.Form("clsname"&Trim(ids(i)))
		orderx=Request.Form("clsorder"&Trim(ids(i)))
		If Trim(ClsName)="" Then 
			ExComm.ShowMsg "分类名称不能为空",""
		End If 
		If Trim(orderx)="" Or IsNumeric(orderx)=False Then 
			ExComm.ShowMsg "分类序号不能为空,并且是数字",""
		End If 
		If(Trim(clsname)<>"" And orderx<>"") Then 
			Sql="update Ex_LinksCls set Clsname='"&clsname&"',orderx="&orderx&" where id="&ids(i)
			Conn.Execute Sql
		Else 
			ExComm.ShowMsg "分类名称和序号必须填写",""
		End If 
	Next 
	RefreshLinks
	ExComm.ShowMsg "分类修改成功",""
End Sub 
Sub ClsDel
	Dim id
	id=CInt(Request.QueryString("id"))
	Conn.Execute "delete * from Ex_LinksCls where id="&id
	Conn.Execute "delete * from Ex_Links where parentid="&id
	RefreshLinks
	ExComm.ShowMsg "分类删除成功",Request.Servervariables("http_referer")
End Sub 
Sub RefreshLinks
	ExComm.ClearCaches(sn)
	Dim ExSkin
	Set ExSkin=new Ex_SkinCls
	ExSkin.RefreshSkinCache
	Set ExSkin=Nothing 
End Sub 
Sub Change()
 Dim id,linkname,linkurl,linklogo,isshow,i,num,rs,strsql,ids,parentid
	ids=ExComm.G(request.Form("ids"))
	ids=split(ids,",")
	for i=0 to ubound(ids)
		linkurl=ExComm.G(request.form("linkurl"&trim(ids(i))))
		linkname=ExComm.G(request.form("linkname"&trim(ids(i))))
		linklogo=ExComm.G(request.form("linklogo"&trim(ids(i))))
		isshow=ExComm.G(request.form("isshow"&trim(ids(i))))
		parentid=ExComm.G(request.form("cls"&trim(ids(i))))
		If linkurl="" Or linkname="" Or parentid="" Then 
			ExComm.ShowMsg "网站名称、网站地址和连接分类不能为空",""
		End If 
		strsql="update Ex_links set linkname='"&linkname&"',linkurl='"&linkurl&"'"
		if linklogo<>"" then
			strsql=strsql&",linklogo='"&linklogo&"'"
		end If
		If Trim(linklogo)="" Or linklogo="无" Then
			strsql=strsql&",logoexist=0"
		Else
			strsql=strsql&",logoexist=1"
		End if
		if isshow<>"" then
			strsql=strsql&",isshow="&isshow
		Else
			strsql=strsql&",isshow=false"
		end if
		strsql=strsql&",parentid="&parentid&" where id="&trim(ids(i))
		Conn.execute(strsql)
	Next
	RefreshLinks
	ExComm.ShowMsg "连接已经修改成功",""
 end sub%>
 <%sub del()
 dim id,strsql
 id=request.QueryString("id")
 strsql="delete from Ex_links where id="&id
 Conn.execute(strsql)
 RefreshLinks
 ExComm.ShowMsg "删除成功",request.servervariables("http_referer")
  end Sub
  Sub Add()
	Dim LinkName,LinkUrl,LinkLogo,parentid
	LinkName=ExComm.G(Request("LinkName"))
	LinkUrl=ExComm.G(Request("LinkUrl"))
	LinkLogo=ExComm.G(Request("LinkLogo"))
	parentid=ExComm.F(Request.Form("cls"))
	If LinkLogo="" Then 
		LinkLogo="无"
	End If 
	Conn.Execute "insert into Ex_Links (linkname,linkurl,linklogo,isshow,parentid) values ('"&LinkName&"','"&LinkUrl&"','"&LinkLogo&"',"&True&","&parentid&")"
	RefreshLinks
	ExComm.ShowMsg "连接添加成功",request.servervariables("http_referer")
  End Sub
  %>
</body>
</html>
