<!--#include file="conn.asp"-->
<!--#include file="inc/const.asp"-->
<!--#include file="inc/dv_clsother.asp" -->
<!--#include file="inc/dv_loadcache.asp"-->

<%
'程序作者：未知
'美化作者：小璐璐
'论坛网址：http://chinatms.kmip.net

Dvbbs.LoadTemplates("")
Dvbbs.Nav()
Dvbbs.Head_var 0,"","友情链接","Plus_link.asp"
Call main()

Dvbbs.Footer



Dim msg1
Sub main()

Select Case request("action")
	Case "save1"
		save1()
	Case "self"
		self()
	Case Else		
		GetBbsList()
End Select
End Sub
		



Sub GetBbsList()
%>
<table border="0" cellspacing="1" cellpadding="3" class=tableborder1>
<% if Dvbbs.master then%>
<tr><th height="20" align="center" valign="middle">[<a href="plus_link_admin.asp" title="友情连接高级管理...">进入连接管理</a>]</th>
</tr><% end if %><tr><td class=tablebody1>
<!------>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
  <td width="70%" height="111" valign="middle" class=tablebody1>
  <table width="98%" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td height="20" class="tablebody1">≡ 链接要求 ≡</td>
    </tr>
    <tr>
      <td height="20" class="tablebody1">1. 您的网站需要拥有顶级域名 </td>
    </tr>
    <tr>
      <td height="20" class="tablebody1">2. 文字、Logo不限,但需先做好本站链接 </td>
    </tr>
    <tr>
      <td height="20" class="tablebody1">3. 做好本站链接之后,请到 <a href="plus_link_self.asp">这里</a> 申请本站的链接</td>
    </tr>
    <tr>
      <td height="20" class="tablebody1">4. 如果您的站超过一定时间不能访问,我们将去除您的链接而不另行通知 </td>
    </tr>
  </table></td>
  <td width="30%" valign="middle" class=tablebody1><table width="100%"  border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td align="center"><a href="plus_link.asp?action=self"><font color=red>进入申请链接</font></a></td>
    </tr>
  </table></td>
</tr></table></td></tr></table>
<!------>
<%
Dim Rs,Sql,M,I,K,PerL,ImgPerL
	M=0 :  K=0 
	PerL = 6  '每行多少个文字链接
	ImgPerL = 7  '每行多少个图标链接，璐璐05.05.06更新
	Sql="Select Boardname,Readme,Url,Logo,Islogo From [Dv_bbslink]" 
	Set Rs=DVbbs.Execute(sql)
If Not Rs.Eof Then
		Sql=Rs.Getrows(-1)
	End If
Rs.Close:set Rs=Nothing
'============================ 文字链接
Response.Write "<table border=""0"" cellpadding=""3"" cellspacing=""1"" class=tableborder1>"
Response.Write "<tr><td height=""56"" valign=""middle"" class=""tablebody1"">"
Response.Write "<table width=""98%"" height=""90%"" align=""center"" cellpadding=""0"" cellspacing=""0"">"
Response.Write "<tr><td height=""50"" class=""tablebody1""><a href=""http://bbs.swsq.net/""  target=""_blank"">≡流淌的岁月≡</a>友情联盟</td></tr>"

	K=0
	For I=0 To Ubound(Sql,2)
		If Sql(4,I)=0 Then
			If (K Mod PerL)=0 and K>0 Then Response.Write "<tr>"
			Response.Write "<td align=""left"" class=""tablebody1""><a href="""&SQL(2,i)&""" target=""_blank"" title="""&SQL(1,i)&""">"&SQL(0,i)&"</a></td>"
			K=K+1
		End If
	Next
	For I=1 to PerL-(K Mod PerL)
		If K=PerL or K=0 Then Exit For
		Response.Write"<td width="""&Cint(100/PerL)&"%"" class=""tablebody1""></td>"
	Next
	If K>0 Then Response.Write"</tr>"
	Response.Write "</td></tr></table></td></tr></table>"

'============================ 图片链接

Response.Write "<table border=""0"" cellpadding=""3"" cellspacing=""1"" class=tableborder1>"
Response.Write "<tr><td height=""56"" valign=""middle"" class=""tablebody1"">"
Response.Write "<table width=""98%"" height=""90%"" align=""center"" cellpadding=""0"" cellspacing=""0"">"
Response.Write "<tr><td height=""20"" class=""tablebody1"">≡ 图片链接 ≡</td></tr>"
	If Ubound(Sql,2)=0 Then
 		Response.Write "目前还没有友情链接!"
	Else
		For I=0 To Ubound(Sql,2)
			If Sql(4,I)=1 Then
				If (K Mod ImgPerL)=0 and K>0 Then Response.Write "<tr>"
				Response.Write "<td width="""&Cint(100/ImgPerL)&"%"" align=""left"" class=""tablebody1"" height=""39""><a href="""&SQL(2,i)&""" target=""_blank""><img src="&SQL(3,i)&" border=0 width=""88"" height=""31"" title="""&SQL(1,i)&"""/></a></td>"
				K=K+1
			End If
		Next
		For I=1 to ImgPerL-(K Mod ImgPerL)
			If K=ImgPerL Then Exit For
			Response.Write"<td width="""&Cint(100/ImgPerL)&"%"" class=""tablebody1""></td>"
		Next
	End If
Response.Write "</tr></table></td></tr>"
Response.Write "</table><br>"		
%>

<%
End Sub

Sub self()

if not Dvbbs.Founduser then
	msg1= "您还没有<a href=login.asp>登录论坛</a>，不能使用自助链接功能。如果您还没有<a href=reg.asp>注册</a>，请先<a href=reg.asp>注册</a>！"
	d_error()
	else
	GetBbsList1()
end if
End Sub

Sub GetBbsList1()
	
%>

<!--##加入友情连接插件的处理部分##-->
<table border="0" cellpadding=3 cellspacing=1 class=tableborder1>
<tr>
<th width="982" height=25 colspan=2 align=center valign=middle><b>本站链接信息</b>
</th></tr><tr>
<td class="tablebody1"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
<tr><td width="80%">
<table width="98%" border="0" align="center" cellpadding="3" cellspacing="0">
<tr><td width="78">站点名称</td>
<td width="667"><font color="#0000FF">流淌的岁月影视论坛</font></td>
</tr><tr>
<td width="78"> 链接地址</td>
<td><font color="#FF0000">http://bbs.swsq.net</font></td>
</tr><tr>
<td width="78"> Logo地址</td>
<td><font color="#FF0000">http://bbs.swsq.net/logo.gif</font></td>
</tr><tr>
<td width="78">站点简介</td>
<td><font color="#990000">免费电影天天更新，好电影任你下载！</font></td>
</tr></table></td>
<td width="20%" align="center"><% if Dvbbs.master then%>[<a href="plus_link_admin.asp" title="友情连接高级管理...">进入连接管理</a>] 
<% end if %></td>
</tr></table></td><tr>
<th colspan=2 align=center>申请友情链接</th></tr>
<tr><td colspan=2 align=center class="tablebody1">
  <table width="100%"  border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td width="80%"><table width="98%" border="0" align="center" cellpadding="3" cellspacing="0">
        <script Language="JavaScript" Type="text/javascript">
<!--
function FrontPage_Form1_Validator(theForm)
{

  var radioSelected = false;
  for (i = 0;  i < theForm.islogo.length;  i++)
  {
    if (theForm.islogo[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("请选择“islogo”选项中的一项。");
    return (false);
  }
  return (true);
}
//-->
      </script>
        <form action="plus_link.asp?action=save1" method = POST onsubmit="return FrontPage_Form1_Validator(this)" language="JavaScript" name="FrontPage_Form1">
          <tr>
            <td width="11%" height=25 >站点名称</td>
            <td width="89%"><input type="text" name="name" size=90></td>
          </tr>
          <tr>
            <td width="11%" height=25 >链接地址</td>
            <td><input type="text" name="url" size=90></td>
          </tr>
          <tr>
            <td width="11%" height=25  >Logo地址</td>
            <td><input type="text" name="logo" size=90></td>
          </tr>
          <tr>
            <td width="11%" height=25  >站点简介</td>
            <td><input type="text" name="readme" size=90></td>
          </tr>
          <tr>
            <td width="11%" height=25  >链接类型</td>
            <td><input type="radio" value="0" checked name="islogo">
        文字链接
          <input type="radio" value="1"  name="islogo">
        图片链接</td>
          </tr>
          <tr>
            <td colspan=2 height=25 align="center"><input type="submit" value="提交" name="submit">
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              <input type="reset" value="重置" name="reset"></td>
          </tr>
        </form>
      </table></td>
      <td width="20%" valign="top"><strong>链接提示：</strong><br>        <br>
        申请与本站点链接的，请先与本站做好链接，再进行申请。我们将不定期检查链接网站，如果发现是无效网址，或是没有与本站做好链接的，都一律在不通知的情况下，取消其在本站的所有链接。</td>
    </tr>
  </table></td>
</tr></table>
<%
End Sub
sub save1()

if Request("url")<>"" and Request("readme")<>"" and request("name")<>"" then

    If Not IsObject(Conn) Then ConnectionDatabase

	dim linknum,rs,sql
	set rs= server.createobject ("adodb.recordset")
	sql = "select * from dv_bbslink order by id desc"
	rs.Open sql,conn,1,3
	if rs.eof and rs.bof then
	linknum=1
	else
	linknum=rs("id")+1
	end if
	sql="insert into dv_bbslink(id,boardname,readme,logo,url,islogo) values("&linknum&",'"&fixjs(Trim(Request.Form ("name")))&"','"&fixjs(Trim(Request.Form ("readme")))&"','"&fixjs(trim(request.Form("logo")))&"','"&fixjs(Request.Form ("url"))&"',"&CInt(request.Form("islogo"))&")"
	Dvbbs.Execute(sql) 
	rs.Close
	set rs=Nothing 
	
	
	msg1="请等待管理员审核。请在贵论坛加好本论坛的链接。"

    d_error
    msga1()
else

    msg1="请输入有效的链接信息。"

	d_error
	
end if
end sub

Sub d_error() 
%>
<table align="center" cellpadding=3 cellspacing=1  class=tableborder1>
<tr align=center>
<th height=20 colspan=2 width="100%">提示信息</th>
</tr><tr>
<td width="100%" colspan=2 align="center" class="tablebody1">
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
<tr><td height="30" align="center">
<%
	 Response.Write msg1	 
%>
</td>
</tr><tr>
<td height="20" align="center"><a href="plus_link.asp">>> 返回</a></td>
</tr></table></td></tr></table>	
<%

End Sub 

Function fixjs(Str)
	If Str <>"" Then
		str = replace(str,"\", "\\")
		Str = replace(str, chr(34), "\""")
		Str = replace(str, chr(39),"\'")
		Str = Replace(str, chr(13), "\n")
		Str = Replace(str, chr(10), "\r")
		str = replace(str,"'", "&#39;")
	End If
	fixjs=Str
End Function
Function enfixjs(Str)
	If Str <>"" Then
		Str = replace(str,"&#39;", "'")
		Str = replace(str,"\""" , chr(34))
		Str = replace(str, "\'",chr(39))
		Str = Replace(str, "\r", chr(10))
		Str = Replace(str, "\n", chr(13))
		Str = replace(str,"\\", "\")
	End If
	enfixjs=Str
End Function

sub msga1()
dim sqlm1,aname,rs,sql

set rs= server.createobject ("adodb.recordset")
	sql="Select Username From [Dv_User] where UserGroupID=1 " '5月6日更新
	rs.open sql,conn,1,1
Do While Not Rs.EOF

      aname=rs("username")
       
      sqlm1="insert into dv_message(sender,incept,title,content,sendtime,issend)values('友情链接','"&aname&"','很高兴的通知您：','"&Dvbbs.membername&"申请友情链接，请[URL=Plus_link.asp]查看[/URL]。','"&now()&"','1')"
      Dvbbs.execute (sqlm1)    
       rs.movenext
loop	  

    rs.Close
	set rs=Nothing
				
end sub
%>