<!--#include file="tgzcm_Conn.asp"-->
<!--#include file="tgzcm_Check.asp"-->
<!--#include file="../tgzcm.Cache/tgzcm.Admin.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<TITLE>管理页面</TITLE>
<link href="skins/css/tgzcm_main.css" rel="stylesheet" type="text/css" />
<script language = "javaScript" src = "tgzcm_All.js" type="text/javascript"></script>
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <th colspan=7 style="text-align:center;"><strong>友情链接系统</strong></th>
  </tr>
  <tr style="text-align:center;">
    <td width="30" class="td2">ID</td>
    <td width="100" class="td2">网站名称</td>
    <td width="200" class="td2">网站地址</td>
    <td width="200" class="td2">网站LOGO</td>
    <td class="td2" style="text-align:left">相关操作</td>
  </tr> 
<%
Dim Action,Linkid,LinkName,LinkUrl,LinkLogo
Action=Trim(Request.QueryString("action"))
Page=int(request.QueryString ("page"))
If page<=0 Or page="" Then page=1'初始化分页参数
Linkid=Trim(Request.QueryString("id"))
LinkName=Trim(Request.Form("link_name"))
LinkUrl=Trim(Request.Form("link_url"))
LinkLogo=Trim(Request.Form("link_logo"))

If action="add" then
    Call link_add()
Elseif action="edit" Then
    Call link_edit()
Elseif action="del" then
    Call link_del()
Elseif action="delall" then
    Call link_delall()	
Elseif action="add_save" Then
    Call add_save()
Elseif action="edit_save" Then
    Call edit_save()		
Else 
    Call link_main() 
End If
%> 
<!--主页面 --> 
<%Sub link_main()%>  
<%
Set rs = Server.CreateObject("adodb.recordset")
sql = "select * from tgzcm_link order by link_id desc"
rs.Open sql, Conn, 1, 1
If Not (rs.bof And rs.eof) Then
	i=0
	rs.pagesize=tgzcmId(7)'每页数据
	rs.AbsolutePage=page
	m=rs.recordcount     '总记录
	n=rs.PageCount       '总页数
	z=rs.pagesize        '每页数量
	do while not rs.eof and i<rs.pagesize
%>
  <tr style="text-align:center;">
    <td class="td1"><%=rs("link_id")%>.</td>
    <td class="td1"><a href="<%=rs("link_url")%>" target="_blank"><%=rs("link_name")%></a></td>
    <td class="td1"><%=rs("link_url")%></td>
    <td class="td1"><a href="<%=rs("link_url")%>" target="_blank" style="border:1px solid #CCCCCC"><img src="<%=rs("link_logo")%>" width="88" height="31" border="0"></a></td>
    <td class="td1" style="text-align:left"><a href="?action=edit&id=<%=rs("link_id")%>">编辑</a>　<a href="#" onClick="javascript:tgzcmdel('?action=del&id=<%=rs("link_id")%>','您将删除这个友链!!','该操作不可恢复，确认吗？');">删除</a></td>
  </tr>
<%
    i=i+1
    rs.movenext  
    loop 
Else
    Response.Write("<tr><td>暂时没有友情链接！</td></tr>")	
End If
rs.Close
set rs=nothing
Call CloseConn()'关闭数据库连接
%>
  <tr >
    <td colspan="5" class="td1" style="padding-left:100px;"><%=ShowPage("tgzcm_Link.asp", m, z, page, True, True, "条", False)%></td>
  </tr>
<%End Sub%> 

<!--新加友情链接 -->
<%Sub link_add()%>  
<form method="post" action="?action=add_save" name="添加">
<tr style="text-align:center;">
  <td class="td1">添加</td>
  <td class="td1"><input size=12 type="text" name="link_name" onFocus="if(this.value=='网站名称')this.value='';" value="网站名称" style="color: #999"></td>
  <td class="td1"><input size=25  type="text" name="link_url"  onfocus="if(this.value=='网站地址')this.value='http://';" value="网站地址" style="color: #999"></td>
  <td class="td1"><input size=25  type="text" name="link_logo"  onfocus="if(this.value=='http://www.tgzcm.com/images/logo.gif')this.value='';" value="http://www.tgzcm.com/images/logo.gif" style="color: #999"></td>
  <td class="td1" style="text-align:left"><input type="submit" value="添 加" name="Submit"></td>
  </tr>
</form>
<%End Sub%>

<!--编辑友情链接 -->
<%
Sub link_edit() 
Set rs = Server.CreateObject("adodb.recordset")
sql = "select * from tgzcm_link where link_id="&clng(Linkid)&""
rs.Open sql, Conn, 1, 3
    If not(rs.bof And rs.eof) Then
%> 
<form method="post" action="?action=edit_save&id=<%=rs("link_id")%>" name="修改">
<tr style="text-align:center;">
  <td class="td1"><%=rs("link_id")%>.</td>
  <td class="td1"><input size=12 type="text" name="link_name"  value="<%=rs("link_name")%>" style="color: #999"></td>
  <td class="td1"><input size=25  type="text" name="link_url"  value="<%=rs("link_url")%>" style="color: #999"></td>
  <td class="td1"><input size=25  type="text" name="link_logo" value="<%=rs("link_logo")%>" style="color: #999"></td>
  <td class="td1" style="text-align:left"><input type="submit" value="确定修改" name="Submit"> <input type="button" value="返回取消" name="Submit" onClick="javascript:history.go(-1)"></td>
  </tr>
</form>
<%
    Else
		Response.Write("<tr><td>暂时没有友链信息，请保留www.tgzcm.com的友链以提升本站的权重，这样本站才能推出更多免费服务！</td></tr>") 
    End If	
End Sub
%> 

<!--保存新加的友情链接 -->
<%
Sub add_save()
    If LinkName="" Or LinkUrl="" Then 
	    Call tgzcm_err_c("必要参数不能为空！")
	    Response.End
    End If
    Conn.Execute("insert into tgzcm_link (link_name,link_url,link_logo) values ('"&LinkName&"','"&LinkUrl&"','"&LinkLogo&"')")
	Response.redirect("?")
End Sub
%>

<!--保存修改后的友情链接 -->
<%
Sub edit_save()
    If LinkName="" Or LinkUrl="" Then 
	    Call tgzcm_err_c("必要参数不能为空！")
	    Response.End
    End If
    Conn.Execute(" update tgzcm_link set link_name='"&LinkName&"',link_url='"&LinkUrl&"',link_logo='"&LinkLogo&"' where link_id="&Linkid&" ")
	Response.redirect("?")
End Sub
%>

<!--删除友情链接 -->
<%
Sub link_del()
    Conn.Execute(" delete from tgzcm_link where link_id="&Linkid&" ")
	Response.redirect("?")
End Sub

Sub link_delall()
    Conn.Execute(" delete from tgzcm_link ")
	Response.redirect("?")
End Sub
%>
</table>
</body>
</html>