<!--#include file="../conn.asp"-->
<!--#include file="admin_check.asp"-->
<!--#include file="../inc/function.asp"-->
<%
Response.Buffer = True 
server.ScriptTimeout=99999
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1 
Response.Expires = 0 
Response.CacheControl = "no-cache"
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>管理页面</title>
<link id="maincss" rel="stylesheet" href="images/css/admin_style_<%= AdminSkin %>.css" type="text/css" media="all" />
<script language="javascript">
function LOGO(str)
  {
  if(str=="")
     {
	 p1.innerHTML='88×31';
	 }
  else
	 {
	 p1.innerHTML='<img src="'+str+'" width="88" height="31" align="absmiddle"/>';
	 }
  }
</script>
</head>
<body leftmargin="0" bottommargin="0" rightmargin="0" topmargin="5" marginheight="0" marginwidth="0" bgcolor="#DDEEFF">
<%Call chkFlag(24)%>
<table class="tableBorder" cellspacing="1" cellpadding="2" width="96%" align="center" border="0">
<tr>
		<th height="25" align="left">友情链接管理</th>
	</tr>
  <tr>
    <td class="TableRow1"><font color="#008800">管理导航：</font><a href='Admin_FriendSite.asp'>友情链接管理首页</a>&nbsp;|&nbsp;<a href='Admin_FriendSite.asp?Act=Add'>添加友情链接</a></td>
  </tr>
</table><br>
<%
Dim Act,id,AskD
Act=Trim(Request.QueryString("Act"))
id=Trim(Request.QueryString("id"))
Set AskD = Server.CreateObject("KwAsk.FunAsk")
	opendb
set AskD.myConn =conn
AskD.myFid=id
AskD.myPredb =predb
   Select Case Act
       Case "Add"
	      call add()
       Case "Del"
	      call del()
	   Case "Chk"
	      Response.Flush()
	      call AskD.chk()
	   Case "ChkAll"
	      call chkall()
	   Case "Save"
	      Call saved()
	   Case "Modi"
	      call modi()
	   Case "ModiUp"
	      call modiup()
	   Case else
	      call main()
   End Select
	set AskD.myConn =Nothing
	closedb
Set AskD = Nothing

sub del()
    dim rs
	set rs=conn.execute("delete from "&predb&"FriendSite where id="&id)
	set rs=nothing
	application.Lock()
	application("friendsite")=""
	application.UnLock()
   Response.Write("<script language=""javascript"">window.location.href='?';</script>")
end sub

sub saved()
	DIM mSite,mSiteName,mSiteUrl,mLogoUrl,mLinkType,mSiteIntro,mQQ,rs,sql
	mSite=Trim(Request.Form("site"))
	mSiteName=Trim(Request.Form("SiteName"))
	mSiteUrl=Trim(Request.Form("SiteUrl"))
	mLogoUrl=Trim(Request.Form("LogoUrl"))
	mLinkType=Trim(Request.Form("LinkType"))
	mSiteIntro=Trim(Request.Form("SiteIntro"))
	mQQ=Trim(Request.Form("qq"))

   SET rs= Server.CreateObject("adodb.recordset")
   sql="select * from "&predb&"FriendSite where SiteUrl='"&mSiteUrl&"' order by ID desc"
   rs.open sql,conn,1,3
   if rs.bof and rs.eof then
	   rs.addnew
	   rs("LinkType")=mLinkType
	   rs("SiteName")=mSiteName
	   rs("SiteUrl")=mSiteUrl
	   rs("SiteIntro")=mSiteIntro
	   rs("LogoUrl")=mLogoUrl
	   rs("SiteAdmin")=mQQ
	   rs("UpdateTime")=now()
	   rs("Passed")=true
	   rs.update
   else
       Call SendMsg("该域名已经建立链接")
       Response.Write("<script>setTimeout(""location.href='?'"",2000)</script>")
       Response.End()  
   end if
   rs.close
   set rs=nothing
   
	application.Lock()
	application("friendsite")=""
	application.UnLock()
   Call SendMsg("链接成功")
   Response.Write("<script>setTimeout(""location.href='?'"",2000)</script>")
   Response.End()
end sub

Sub add()
%>
<table class="tableBorder" cellspacing="1" cellpadding="2" width="96%" align="center" border="0">
    <tr>
		<th height="25" align="left" colspan="2">链接添加</th>
	</tr>
	<tr class="TableRow1" height='22'>
			<td colspan="2" align='center'>&nbsp;</td>
	</tr>
		<form action="?act=Save" method="post" name="site">
	    <tr class='TableRow1' onMouseOut="this.className='TableRow1'" onMouseOver="this.className='TableRow2'"> 
			<td width="134" align='right'>网站名称：</td>      
			<td width="646"><input name="SiteName" type="text" id="SiteName" size="36" />
		    <font color="#FF0000">*</font></td>
		  </tr>
	    <tr class='TableRow1' onMouseOut="this.className='TableRow1'" onMouseOver="this.className='TableRow2'">
	      <td align='right'>网站地址：</td>
	      <td><input name="SiteUrl" type="text" id="SiteUrl" size="36" />
          <font color="#FF0000">*</font></td>
	      </tr>
	    <tr class='TableRow1' onMouseOut="this.className='TableRow1'" onMouseOver="this.className='TableRow2'">
	      <td align='right'>LOGO地址：</td>
	      <td><input name="LogoUrl" type="text" id="LogoUrl" onFocus="p1.innerHTML='';" onBlur="LOGO(this.value)" size="50" /><span id="p1">88×31</span></td>
	      </tr>
	    <tr class='TableRow1' onMouseOut="this.className='TableRow1'" onMouseOver="this.className='TableRow2'">
	      <td align='right'>链接类型：</td>
	      <td><input name="LinkType" type="radio" value="2" checked="checked" />
文字链接
         &nbsp;
         <input type="radio" name="LinkType" value="1" />
LOGO链接</td>
	      </tr>
	    <tr class='TableRow1' onMouseOut="this.className='TableRow1'" onMouseOver="this.className='TableRow2'">
	      <td align='right'>链接到我站的地址：</td>
	      <td><input name="SiteIntro" type="text" id="SiteIntro" size="46" /></td>
	      </tr>
	    <tr class='TableRow1' onMouseOut="this.className='TableRow1'" onMouseOver="this.className='TableRow2'">
	      <td align='right'>联系QQ：</td>
	      <td><input name="qq" type="text" id="qq" size="15"></td>
	      </tr>
	    <tr class='TableRow1' onMouseOut="this.className='TableRow1'" onMouseOver="this.className='TableRow2'">
	      <td align='center'>&nbsp;</td>
	      <td height="30"><input type="submit" name="Submit" value="·添加链接·" /></td>
	      </tr>
		  </form>
        </table>      
<%
End sub

Sub modiup()
	DIM mSite,mSiteName,mSiteUrl,mLogoUrl,mLinkType,mSiteIntro,mQQ,rs,sql
	mSite=Trim(Request.Form("site"))
	mSiteName=Trim(Request.Form("SiteName"))
	mSiteUrl=Trim(Request.Form("SiteUrl"))
	mLogoUrl=Trim(Request.Form("LogoUrl"))
	mLinkType=Trim(Request.Form("LinkType"))
	mSiteIntro=Trim(Request.Form("SiteIntro"))
	mQQ=Trim(Request.Form("qq"))

   SET rs= Server.CreateObject("adodb.recordset")
   sql="select * from "&predb&"FriendSite where id="&id
   rs.open sql,conn,1,3
	   rs("LinkType")=mLinkType
	   rs("SiteName")=mSiteName
	   rs("SiteUrl")=mSiteUrl
	   rs("SiteIntro")=mSiteIntro
	   rs("LogoUrl")=mLogoUrl
	   rs("SiteAdmin")=mQQ
	   rs("UpdateTime")=now()
	   rs("Passed")=true
	   rs.update
   rs.close
   set rs=nothing
   
	application.Lock()
	application("friendsite")=""
	application.UnLock()
   Call SendMsg("修改成功")
   Response.Write("<script>setTimeout(""location.href='?'"",2000)</script>")
   Response.End()
End Sub

Sub modi()
   dim rs,sql
   set rs= Server.CreateObject("adodb.recordset")
   sql="select * from "&predb&"FriendSite where id="&id
   rs.open sql,conn,1,1
%>
<table class="tableBorder" cellspacing="1" cellpadding="2" width="96%" align="center" border="0">
    <tr>
		<th height="25" align="left" colspan="2">链接修改</th>
	</tr>
	<tr  class="TableRow1" height='22'>
			<td colspan="2" align='center'>&nbsp;</td>
	</tr>
		<form action="?act=ModiUp&id=<%= id %>" method="post" name="site">
	    <tr  class="TableRow1" onMouseOut="this.className='TableRow1'" onMouseOver="this.className='TableRow2'"> 
			<td width="134" align='right'>网站名称：</td>      
			<td width="646"><input name="SiteName" type="text" id="SiteName" value="<%=rs("sitename")%>" size="36" />
		    <font color="#FF0000">*</font></td>
		  </tr>
	    <tr  class="TableRow1" onMouseOut="this.className='TableRow1'" onMouseOver="this.className='TableRow2'">
	      <td align='right'>网站地址：</td>
	      <td><input name="SiteUrl" type="text" id="SiteUrl" value="<%=rs("siteurl")%>" size="36" />
          <font color="#FF0000">*</font> 形如“www.kuaishow.com” 不要http://</td>
	      </tr>
	    <tr  class="TableRow1" onMouseOut="this.className='TableRow1'" onMouseOver="this.className='TableRow2'">
	      <td align='right'>LOGO地址：</td>
	      <td><input name="LogoUrl" type="text" id="LogoUrl" onFocus="p1.innerHTML='';" onBlur="LOGO(this.value)" value="<%=rs("LogoUrl")%>" size="50" /><span id="p1">88×31</span></td>
	      </tr>
	    <tr  class="TableRow1" onMouseOut="this.className='TableRow1'" onMouseOver="this.className='TableRow2'">
	      <td align='right'>链接类型：</td>
	      <td><input name="LinkType" type="radio" value="2" <% If rs("LinkType")=2 Then %>checked="checked"<% End If %> />
文字链接
         &nbsp;
         <input type="radio" name="LinkType" value="1" <% If rs("LinkType")=1 Then %>checked="checked"<% End If %>/>
LOGO链接</td>
	      </tr>
	    <tr  class="TableRow1" onMouseOut="this.className='TableRow1'" onMouseOver="this.className='TableRow2'">
	      <td align='right'>链接到我站的地址：</td>
	      <td><input name="SiteIntro" type="text" id="SiteIntro" value="<%=rs("SiteIntro")%>" size="46" /></td>
	      </tr>
	    <tr  class="TableRow1" onMouseOut="this.className='TableRow1'" onMouseOver="this.className='TableRow2'">
	      <td align='right'>联系QQ：</td>
	      <td><input name="qq" type="text" id="qq" value="<%=rs("SiteAdmin")%>" size="15"></td>
	      </tr>
	    <tr  class="TableRow1" onMouseOut="this.className='TableRow1'" onMouseOver="this.className='TableRow2'">
	      <td align='center'>&nbsp;</td>
	      <td height="30"><input type="submit" name="Submit" value="·修改链接·" /></td>
	      </tr>
		  </form>
        </table>      
<%
rs.close
set rs=nothing
End sub


Sub Main()
%>
<table class="tableBorder" cellspacing="1" cellpadding="2" width="96%" align="center" border="0">
    <tr>
		<th height="25" colspan="8" align="left">链接列表</th>
	</tr>
    <tr>
        <td width='80' align='center' class="TableRow2"><strong>是否链接我</strong></td>
        <td align='center' class="TableRow2"><strong>网站名称</strong></td>
        <td width='126' align='center' class="TableRow2"><strong>网站LOGO</strong></td>
        <td width='87' align='center' class="TableRow2"><strong>站长</strong></td>          
        <td width='24' align='center' class="TableRow2"><strong>PR</strong></td>          
        <td width='68' align='center' class="TableRow2"><strong>百度</strong></td>          
        <td width='68' align='center' class="TableRow2"><b>GOOGLE</b></td>          
        <td width='138' align='center' class="TableRow2"><strong>操作</strong></td>
    </tr>
		<%
		dim rs,sql
		set rs= Server.CreateObject("adodb.recordset")
		sql="select * from "&predb&"FriendSite order by id desc"
		rs.open sql,conn,1,1
  if not(rs.bof and rs.eof) then
 dim page,maxperpage,n,i
        page=clng(Request.QueryString("page"))
        maxperpage=40  '最大每页数
        If rs.recordcount Mod maxperpage = 0 Then
            n = rs.recordcount \ maxperpage
        else
            n = rs.recordcount \ maxperpage + 1
        end If
		if page>n then page=n
		if page<1 then page=1
     '关键分页设置
        rs.move (Page-1)*MaxPerPage
        dim bookmark
        bookmark=rs.bookmark
     '关键分页设置

		do while not rs.eof
		%>
	    <tr class="TableRow1" onMouseOut="this.className='TableRow1'" onMouseOver="this.className='TableRow2'"> 
			<td align='center'><b><% If rs("Elite")=True Then %><font color="#0000FF">√</font><% Else %><font color="#FF0000">×</font><% End If %></b></td>      
			<td><a href='http://<%= rs("siteurl") %>' target='_blank'><%= rs("sitename") %></a></td>
			<td align='center'><% if rs("logourl")<>"" and rs("logourl")<>"http://" then %><img src='<%= rs("logourl") %>' width='88' height='31' border='0'><% End If %></td>
			<td align='center'><%= rs("siteadmin") %></td>
			<td align='center'><%= rs("KindID") %></td>    
			<td align='center'><% If rs("SpecialID")<1 Then %><font color="#FF0000"><%= rs("SpecialID") %></font><% Else %><%= rs("SpecialID") %><% End If %></td>          
			<td align='center'><% If rs("Hits")<1 Then %><font color="#FF0000"><%= rs("Hits") %></font><% Else %><%= rs("Hits") %><% End If %></td>          
			<td align='center'><a href='?Act=Chk&ID=<%= rs("id") %>'>检查</a>&nbsp;&nbsp; <a href='?Act=Modi&ID=<%= rs("id") %>'>修改</a>&nbsp;&nbsp; <a href='?Act=Del&ID=<%= rs("id") %>' onClick="return confirm('确定要删除此友情链接站点吗？');">删除</a></td>        
	    </tr>
		<%
		rs.movenext
	       i=i+1
	       if i>=MaxPerPage then exit do
		loop
		%>
	<tr>
	  <td colspan="8" align="center" class="TableRow2">
     共计 <font color="#FF0000"><b><%= rs.recordcount %></b></font> 条 
	<a href="?page=1">首页</a> 
	<a href="?page=<%=page-1%>">上一页</a> 
	<a href="?page=<%=page+1%>">下一页</a>&nbsp;&nbsp;
	<a href="?page=<%=n%>">尾页</a>&nbsp;&nbsp;
	页次：<b><font color="#FF0000"><%= page %></font>/<%= n %></b>页 
	<b><%= maxperpage %></b>条/页&nbsp;&nbsp;
	转到：
	<select name="page" onChange="javascript:window.location='?page='+this.options[this.selectedIndex].value;">
	  <%
	  dim ii
	  for ii=1 to n%>
	  <option value="<%=ii%>" <%if page=ii then%>selected<%end if%>><%=ii%></option>
	  <%next%>
	</select>
      </td>
  </tr>
</table>
<%
end if
rs.close
set rs=nothing
End Sub
%>
<br>
</body>
</html>