<!-- #include file=../../inc/BBSsetup.asp -->
<!-- #include file=../../inc/Board_popfun.asp -->
<!-- #include file=../inc/bbsmanage_Fun.asp -->
<%
DEF_BBS_HomeUrl = "../../"
Const MaxLinkNum = 100
Dim GBL_ID
initDatabase
GBL_CHK_TempStr = ""
GBL_ID = checkSupervisorPass

Dim ReqN,WriteN

SiteHead(DEF_SiteNameString & " - 管理员")
%>
<table width="<%=DEF_BBS_ScreenWidth%>" border="0" cellspacing="1" cellpadding="0" align="center" bgcolor="<%=DEF_BBS_DarkColor%>" class=TBone>
  <tr> 
    <td width="<%=DEF_BBS_LeftTDWidth%>" bgcolor="<%=DEF_BBS_LightColor%>" class=TBBG1 valign="top"> 
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td><%If GBL_CHK_Flag=1 Then DisplayUserCenter%></td>
        </tr>
      </table>
    </td>
    <td valign="top" bgcolor=<%=DEF_BBS_LightestColor%> class=TBBG9> <br>
      <table width="90%" border="0" cellspacing="0" cellpadding="0" align="center">
        <tr> 
          <td height="20"> 
            <p><a href="<%=DEF_BBS_HomeUrl & """>" & DEF_BBS_Name & "</a> &gt;&gt; <a href=""" & DEF_BBS_HomeUrl%>manage/">管理系统</a> &gt;&gt; 友情论坛<br>
	<%If GBL_CHK_Flag=1 Then
		SiteLink
	Else%>
		<table width=96%>
		<tr>
		<td>
		<%
		If Request("submitflag")="" Then
			Response.Write "<br><b>请先登陆</b>"
		Else
			Response.Write "<br><p align=left><font color=ff0000 class=RedFont><b>" & GBL_CHK_TempStr & "</b></font>"
		End If
		DisplayLoginForm
		Response.Write "</p>"%>
		</td>
		</tr>
		</table>
	<%End If%>
            </p>
            </td>
        </tr>
      </table>
      
      <br>
      <br>
    </td>
  </tr>
</table>
<%closeDataBase
SiteBottom
If GBL_ShowBottomSure = 1 Then Response.Write GBL_SiteBottomString

Function SiteLink

ReqN = 0
WriteN = 0
%>
<form name="pollform3sdx" method="post" action="SiteLink.asp" onsubmit="return checksubmit();">
<input type="hidden" name="SubmitFlag" value=yes>
<p>
	<b>
		修改友情链接</b><font color=8888888 class=GrayFont>(下面是所有友情网站的信息，除去网站名表示删除，要增加请点下面的增加按钮)</font>
</p>
<%If Request("SubmitFlag") <> "" Then
	CheckLinkValue
End If%>
<b><font color=ff0000 class=RedFont><%=GBL_CHK_TempStr%></font></b>
<p>
<div name=SiteString id=SiteString>
<%
If Request("SubmitFlag") <> "" Then
	If GBL_CHK_TempStr <> "" Then
		If Request("SiteName1") = "" Then
			WriteN = 1%>
			<p>网站1<br>
			网站名称：<input type="text" name="SiteName1" maxlength="100" size="50" class=fminpt>(最长100字，允许HTML)<br>
			网站地址：<input type="text" name="SiteUrl1" maxlength="255" size="50" class=fminpt><br>
			LOGO地址：<input type="text" name="LogoUrl1" maxlength="255" size="50" class=fminpt><br>
			LOGO宽度：<input type="text" name="LogoWidth1" maxlength="5" size="5" value=88 class=fminpt><br>
			LOGO高度：<input type="text" name="LogoHeight1" maxlength="5" size="5" value=31 class=fminpt><br>
			是否换行：<input type="text" name="BreakFlag1" maxlength="5" size="5" class=fminpt>另起一行排版，1-换行，0-自动<br>
			排列顺序：<input type="text" name="OrderID1" maxlength="5" size="5" class=fminpt>越小越前面<br>
		<%Else
			For ReqN = 1 to MaxLinkNum
				If Request("SiteName" & ReqN) <> "" Then
					WriteN = WriteN + 1
			%>
			<p>网站<%=ReqN%><br>
			网站名称：<input type="text" name="SiteName<%=ReqN%>" maxlength="100" size="50" Value="<%=htmlencode(Request("SiteName" & ReqN))%>" class=fminpt>(最长100字，允许HTML)<br>
			网站地址：<input type="text" name="SiteUrl<%=ReqN%>" maxlength="255" size="50" Value="<%=htmlencode(Request("SiteUrl" & ReqN))%>" class=fminpt><br>
			LOGO地址：<input type="text" name="LogoUrl<%=ReqN%>" maxlength="255" size="50" Value="<%=htmlencode(Request("LogoUrl" & ReqN))%>" class=fminpt><br>
			LOGO宽度：<input type="text" name="LogoWidth<%=ReqN%>" maxlength="5" size="5" Value="<%=htmlencode(Request("LogoWidth" & ReqN))%>" class=fminpt><br>
			LOGO高度：<input type="text" name="LogoHeight<%=ReqN%>" maxlength="5" size="5" Value="<%=htmlencode(Request("LogoHeight" & ReqN))%>" class=fminpt><br>
			是否换行：<input type="text" name="BreakFlag<%=ReqN%>" maxlength="5" size="5" Value="<%=htmlencode(Request("BreakFlag" & ReqN))%>" class=fminpt>另起一行排版，1-换行，0-自动<br>
			排列顺序：<input type="text" name="OrderID<%=ReqN%>" maxlength="5" size="5" Value="<%=htmlencode(Request("SiteUrl" & ReqN))%>" class=fminpt>越小越前面<br>
			<%
				End If
			Next
		End if
	Else
		SaveSiteLink
		Response.Write "成功更新！"
		MakeDataBaseLinkFile
		Response.Write "<br>成功产生动态文件！"
		Exit Function
	End If
Else
	DisplayDatabaseLink
End If
%>

</div>
<input type=submit name=提交 value=提交 class=fmbtn>
<input type=button name=add value=增加友情链接 onclick="additem();" class=fmbtn>
</form>
注意，如果你的服务器不支持FSO，将不能自动产生首页友情链接，<br>请手动更改inc\IncHtm\BoardLink.asp的文件内容
<script language=javascript>
var maxNumber=<%=MaxLinkNum%>;
var Number=<%=WriteN%>;
function checksubmit()
{
	return true
}

function additem()
{
	Number+=1;
	if(Number>maxNumber)
	{
		alert("已经达到最大友情链接项目，不能再增加!");
	}
	else
	{
		top.SiteString.innerHTML+="<p>网站"+Number+"<br>";
		top.SiteString.innerHTML+="网站名称：<input type=text name=SiteName"+Number+" maxlength=100 size=50 class=fminpt><br>";
		top.SiteString.innerHTML+="网站地址：<input type=text name=SiteUrl"+Number+" maxlength=255 size=50 class=fminpt><br>";
		top.SiteString.innerHTML+="LOGO地址：<input type=text name=LogoUrl"+Number+" maxlength=255 size=50 class=fminpt><br>";
		top.SiteString.innerHTML+="LOGO宽度：<input type=text name=LogoWidth"+Number+" maxlength=5 size=5 value=88 class=fminpt><br>";
		top.SiteString.innerHTML+="LOGO高度：<input type=text name=LogoHeight"+Number+" maxlength=5 size=5 value=31 class=fminpt><br>";
		top.SiteString.innerHTML+="是否换行：<input type=text name=BreakFlag"+Number+" maxlength=5 size=5 value=0 class=fminpt><br>";
		top.SiteString.innerHTML+="排列顺序：<input type=text name=OrderID"+Number+" maxlength=5 size=5 class=fminpt><br>";
		top.scroll(0, 65000);
	}
}
</script>
<%

End Function

Function DisplayDatabaseLink

	Dim Rs,SQL,GetData
	Set Rs = Server.CreateObject("ADODB.RecordSet")
	SQL = "select ID,SiteName,SiteUrl,LogoUrl,OrderID,LogoWidth,LogoHeight,BreakFlag from LeadBBS_Link order by OrderID"
	Rs.Open SQL,con,1,1
	If Rs.Eof Then
		Rs.Close
		Set Rs = Nothing
		WriteN = 1
		%>
		<p>网站1<br>
		网站名称：<input type="text" name="SiteName1" maxlength="100" size="50" class=fminpt>(最长100字，允许HTML)<br>
		网站地址：<input type="text" name="SiteUrl1" maxlength="255" size="50" class=fminpt><br>
		LOGO地址：<input type="text" name="LogoUrl1" maxlength="255" size="50" class=fminpt><br>
		LOGO宽度：<input type="text" name="LogoWidth1" maxlength="5" size="5" value=88 class=fminpt><br>
		LOGO高度：<input type="text" name="LogoHeight1" maxlength="5" size="5" value=31 class=fminpt><br>
		是否换行：<input type="text" name="BreakFlag1" maxlength="5" size="5" class=fminpt>另起一行排版，1-换行，0-自动<br>
		排列顺序：<input type="text" name="OrderID1" maxlength="5" size="5" class=fminpt>越小越前面<br>
		<%
		Exit function
	Else
		GetData = Rs.GetRows(-1)
		Rs.Close
		Set Rs = Nothing
	End If

	WriteN = Ubound(GetData,2)+1
	For SQL = 0 To Ubound(GetData,2)
		ReqN = SQL + 1
		If GetData(7,SQL) = True or GetData(7,SQL) = 1 Then
			GetData(7,SQL) = 1
		Else
			GetData(7,SQL) = 0
		End If
		%>
		<p>网站<%=ReqN%><br>
		网站名称：<input type="text" name="SiteName<%=ReqN%>" maxlength="100" size="50" Value="<%=GetData(1,SQL)%>" class=fminpt>(最长100字，允许HTML)<br>
		网站地址：<input type="text" name="SiteUrl<%=ReqN%>" maxlength="255" size="50" Value="<%=GetData(2,SQL)%>" class=fminpt><br>
		LOGO地址：<input type="text" name="LogoUrl<%=ReqN%>" maxlength="255" size="50" Value="<%=GetData(3,SQL)%>" class=fminpt><br>
		LOGO宽度：<input type="text" name="LogoWidth<%=ReqN%>" maxlength="5" size="5" Value="<%=GetData(5,SQL)%>" class=fminpt><br>
		LOGO高度：<input type="text" name="LogoHeight<%=ReqN%>" maxlength="5" size="5" Value="<%=GetData(6,SQL)%>" class=fminpt><br>
		是否换行：<input type="text" name="BreakFlag<%=ReqN%>" maxlength="5" size="5" Value="<%=GetData(7,SQL)%>" class=fminpt>另起一行排版，1-换行，0-自动<br>
		排列顺序：<input type="text" name="OrderID<%=ReqN%>" maxlength="5" size="5" Value="<%=GetData(4,SQL)%>" class=fminpt>越小越前面<br>
		<%
	Next

End Function

Function CheckLinkValue

	Dim N
	Dim SiteName,SiteUrl,LogoUrl,LogoWidth,LogoHeight,BreakFlag,OrderID
	For N = 0 to MaxLinkNum
		SiteName = Trim(Request("SiteName" & N+1))
		SiteUrl = Trim(Request("SiteUrl" & N+1))
		LogoUrl = Trim(Request("LogoUrl" & N+1))
		LogoWidth = Trim(Request("LogoWidth" & N+1))
		LogoHeight = Trim(Request("LogoHeight" & N+1))
		BreakFlag = Trim(Request("BreakFlag" & N+1))
		OrderID = Trim(Request("OrderID" & N+1))
		If SiteName <> "" Then
			'If SiteUrl = "" Then
			'	GBL_CHK_TempStr = "错误，网站" & N + 1 & "的网址未填写．<br>" & VbCrLf
			'	Exit function
			'End If
			
			If LogoUrl <> "" Then
				If isNumeric(LogoWidth) = 0 Then LogoWidth = 0
				LogoWidth = fix(cCur(LogoWidth))
				If isNumeric(LogoHeight) = 0 Then LogoHeight = 0
				LogoHeight = fix(cCur(LogoHeight))
				If LogoWidth < 1 Then LogoWidth = 1
				If LogoWidth > 1000 Then LogoWidth = 1000
				If LogoHeight < 1 Then LogoHeight = 1
				If LogoHeight > 1000 Then LogoHeight = 1000
			Else
				LogoWidth = 88
				LogoHeight = 31
			End If
			
			If BreakFlag <> "1" and BreakFlag <> "0" Then BreakFlag = 0
			
			If isNumeric(OrderID) = 0 Then OrderID = 0
			OrderID = fix(cCur(OrderID))
			If OrderID < 0 Then OrderID = 0
		End If
	Next

End Function

Function SaveSiteLink

	Dim N
	Dim SiteName,SiteUrl,LogoUrl,LogoWidth,LogoHeight,BreakFlag,OrderID
	Con.ExeCute("Delete from LeadBBS_Link")
	For N = 0 to MaxLinkNum
		SiteName = Trim(Request("SiteName" & N+1))
		SiteUrl = Trim(Request("SiteUrl" & N+1))
		LogoUrl = Trim(Request("LogoUrl" & N+1))
		LogoWidth = Trim(Request("LogoWidth" & N+1))
		LogoHeight = Trim(Request("LogoHeight" & N+1))
		BreakFlag = Trim(Request("BreakFlag" & N+1))
		OrderID = Trim(Request("OrderID" & N+1))
		If SiteName <> "" Then
			'If SiteUrl = "" Then
			'	GBL_CHK_TempStr = "错误，网站" & N + 1 & "的网址未填写．<br>" & VbCrLf
			'	Exit function
			'End If
			
			If LogoUrl <> "" Then
				If isNumeric(LogoWidth) = 0 Then LogoWidth = 0
				LogoWidth = fix(cCur(LogoWidth))
				If isNumeric(LogoHeight) = 0 Then LogoHeight = 0
				LogoHeight = fix(cCur(LogoHeight))
				If LogoWidth < 1 Then LogoWidth = 1
				If LogoWidth > 1000 Then LogoWidth = 1000
				If LogoHeight < 1 Then LogoHeight = 1
				If LogoHeight > 1000 Then LogoHeight = 1000
			Else
				LogoWidth = 88
				LogoHeight = 31
			End If
			
			If BreakFlag <> "1" and BreakFlag <> "0" Then BreakFlag = 0
			
			If isNumeric(OrderID) = 0 Then OrderID = 0
			OrderID = fix(cCur(OrderID))
			If OrderID < 0 Then OrderID = 0
			
			Con.ExeCute("insert into LeadBBS_Link(SiteName,SiteUrl,LogoUrl,LogoWidth,LogoHeight,BreakFlag,OrderID)" & _
				" Values('" & Replace(SiteName,"'","''") & "','" & Replace(SiteUrl,"'","''") & "','" & Replace(LogoUrl,"'","''") & "'," & LogoWidth & "," & LogoHeight & "," & BreakFlag & "," & OrderID & ")")
		End If
	Next

End Function


Function MakeDataBaseLinkFile

	Dim fs,outfile
	Set fs = CreateObject("Scripting.FileSystemObject")
	Set outfile=fs.CreateTextFile(Server.Mappath("../../inc/IncHtm/BoardLink.asp"),true)

	Dim Rs,SQL,GetData
	Dim SiteName,SiteUrl,LogoUrl,OrderID,LogoWidth,LogoHeight,BreakFlag
	Set Rs = Server.CreateObject("ADODB.RecordSet")
	SQL = "select ID,SiteName,SiteUrl,LogoUrl,OrderID,LogoWidth,LogoHeight,BreakFlag from LeadBBS_Link order by OrderID"
	Rs.Open SQL,con,1,1
	If Rs.Eof Then
		outfile.Write " "
		outfile.Close
		Set fs=nothing
		Rs.Close
		Set Rs = Nothing
		Exit function
	Else
		GetData = Rs.GetRows(-1)
		Rs.Close
		Set Rs = Nothing
	End If

	outfile.Write "<br><table width=100% border=0 cellspacing=1 cellpadding=6 align=center bgcolor=" & chr(60) & "%=DEF_BBS_DarkColor" & chr(37) & "> class=TBone>" & VbCrLf
	outfile.Write "<tr bgcolor=<" & chr(37) & "=DEF_BBS_LightDarkColor" & chr(37) & ">>" & VbCrLf
	outfile.Write "	<td class=TBHead><img src=images/blank.gif width=2 height=2><br><b><font color=ffffff class=HeadFont>＝友情链接＝</font><b></td></tr>" & VbCrLf
	'outfile.Write "<table width=100% border=0 cellspacing=1 cellpadding=7 align=center bgcolor=" & chr(60) & "%=DEF_BBS_DarkColor" & chr(37) & "> class=TBone>" & VbCrLf
	outfile.Write "<tr bgcolor=<" & chr(37) & "=DEF_BBS_LightestColor" & chr(37) & "> class=TBBG9>" & VbCrLf
	outfile.Write "	<td>" & VbCrLf
	For SQL = 0 To Ubound(GetData,2)
		If GetData(7,SQL) = True or GetData(7,SQL) = 1 Then
			GetData(7,SQL) = 1
		Else
			GetData(7,SQL) = 0
		End If
		outfile.Write " "
		If GetData(2,SQL) <> "" Then outfile.Write "<a href=""" & htmlencode(GetData(2,SQL)) & """ target=_blank>"
		If GetData(3,SQL) <> "" Then
			outfile.Write "<img src=""" & htmlencode(GetData(3,SQL)) & """ width=" & GetData(5,SQL) & " height=" & GetData(6,SQL) & " border=0 title=""" & htmlencode(GetData(1,SQL)) & """ align=absmiddle>"
		Else
			outfile.Write GetData(1,SQL)
		End If
		If GetData(2,SQL) <> "" Then outfile.Write "</a>"
		If GetData(7,SQL) = 1 Then
			outfile.Write "<br><img src=images/blank.gif height=4 width=2><br>"
		End If
	Next
	outfile.Write "	</td>"
	outfile.Write "</tr>"
	outfile.Write "</table>"
	outfile.Close
	Set Fs = Nothing

End Function
%>