<!--#include file = "Startup.asp"-->
<!-- #include file="Function.asp" -->
<%
call adminer()
Call Header()
Call ComeUrl()
%>


<%
Dim Action,FoundErr,ErrMsg

Action=Trim(Request("Action"))
if Action="" Or Action="FriendLinkExamine" then
	call AddFriendLink()
	Call FriendLinkExamine()
elseif Action="FriendLinkManage" then
	call AddFriendLink()
	call FriendLinkManage()
ElseIf Action="AddFriendLinkSave" then
	Call AddSaveFriendLink()
ElseIf Action="ModifySaveFriendLink" Then
	Call ModifySaveFriendLink()
ElseIf Action="ModifyFriendLink" Then
	Call ModifyFriendLink()
ElseIf Action="DelFriendLink" Then
	Call DelFriendLink()
ElseIf Action="SCFriendLink" Then
	Call SCFriendLink()
ElseIf Action="PassFriendLinkManage" Then
	Call PassFriendLinkManage()
Else
	FoundErr=True
	ErrMsg=ErrMsg & "<br><li>参数错误</li>"
end if
if founderr=true then
	call WriteErrMsg()
End if
%>

<%
Sub AddFriendLink()
%>
<Script Language=JavaScript>
function doSubmit(){
	if (document.FriendLinkAppl.SiteName.value==""){
		alert("网站名称不能为空！");
		return false;
	}
	if (document.FriendLinkAppl.SiteAdd.value==""){
		alert("网站地址不能为空！");
		return false;
	}
	if (document.FriendLinkAppl.LinkType.value==1){
		if (document.FriendLinkAppl.SiteLogo.value==""){
			alert("网站LOGO不能为空！");
			return false;
		}
	}
	if (document.FriendLinkAppl.LinkType.value==3){
		if (document.FriendLinkAppl.SiteLogo.value==""){
			alert("网站LOGO不能为空！");
			return false;
		}
	}}
</Script>
<table width="100%"  border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#DEDFDE">
            <form name="FriendLinkAppl" method="post" action="FriendLink.asp?Action=AddFriendLinkSave" onsubmit="return doSubmit()">
              <tr bgcolor="#f7f7f7">
                <td colspan="2" bgcolor="#f7f7f7"><div align="center"><strong>友　情　链　接　添　加</strong></div></td>
              </tr>
              <tr bgcolor="#FFFFFF">
              <td width="120">网站名称：</td>
              <td><input name="SiteName" type="text" class="input_text" id="SiteName" size="50"></td>
            </tr>
            <tr bgcolor="#FFFFFF">
              <td width="120">网站地址：</td>
              <td><input name="SiteAdd" type="text" class="input_text" id="SiteAdd" size="50"></td>
            </tr>
            <tr bgcolor="#FFFFFF">
              <td width="120">网站LOGO：</td>
              <td><input name="SiteLogo" type="text" class="input_text" id="SiteLogo" size="50"></td>
            </tr>
            <tr bgcolor="#FFFFFF">
              <td width="120">链接类型：</td>
              <td><select name="LinkType" class="input_text" id="LinkType">
                <option value="1" selected>图标链接</option>
                <option value="2">文字链接</option>
                <option value="3">合作网站</option>
              </select></td>
            </tr>
            <tr bgcolor="#FFFFFF">
              <td width="120">首页显示：</td>
              <td><input name="HeadShow" type="radio" value="False" checked="checked" />
                否
                  <input type="radio" name="HeadShow" value="True" />
              是</td>
            </tr>
            <tr bgcolor="#FFFFFF">
              <td colspan="2"><div align="center">
                <input type="submit" name="Submit" value=" 提 交 " class="input_submit">
               　  
               <input type="reset" name="Submit" value=" 重 置 " class="input_submit">
</div></td>
            </tr></form>
</table>
<br>
<%
End Sub
%>

<%
Sub FriendLinkExamine()
%>
<%
End Sub
%>

<%
Sub FriendLinkManage()
%>
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td> <select name='FriendSelect' id="FriendSelect" onchange="if(this.options[this.selectedIndex].value!=''){location='FriendLink.asp?Action=FriendLinkManage&F_LinkType='+this.options[this.selectedIndex].value;}">
          <option value='' selected>跳转至…</option>
          <option value="1">图标链接</option>
          <option value="2">文字链接</option>
          <option value="3">合作网站</option>
          <option value="4">未显示网站</option>
	    </select></td>
  </tr>
  <tr>
    <td><img src="images/zw000.gif" width="1" height="5"></td>
  </tr>
</table>

<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#DEDFDE">
  <tr bgcolor="#f7f7f7">
    <td><div align="center"><strong>网站名称</strong></div></td>
    <td><div align="center"><strong>网站LOGO</strong></div></td>
    <td><div align="center"><strong>链接类型</strong></div></td>
    <td><div align="center"><strong>首页</strong></div></td>
    <td><div align="center"><strong>是否显示</strong></div></td>
    <td><div align="center"><strong>修改</strong></div></td>
    <td><div align="center"><strong>删除</strong></div></td>
  </tr>

<%
Dim F_LinkType
F_LinkType=Trim(Request("F_LinkType"))
If F_LinkType="" Then
	sSql="Select F_ID,F_SiteName,F_SiteAdd,F_SiteLogo,F_LinkType,F_HeadShow From FriendLink Where F_Recycle=True And F_ExamMark=True Order By F_ID Desc"
ElseIf F_LinkType=1 Or F_LinkType=2 Or F_LinkType=3 Then
	sSql="Select F_ID,F_SiteName,F_SiteAdd,F_SiteLogo,F_LinkType,F_HeadShow From FriendLink Where F_LinkType="&F_LinkType&"And F_Recycle=True And F_ExamMark=True Order By F_ID Desc"
Else
	sSql="Select F_ID,F_SiteName,F_SiteAdd,F_SiteLogo,F_LinkType,F_HeadShow From FriendLink Where F_Recycle=False And F_ExamMark=True Order By F_ID Desc"
End If
oRs.Open sSql,oConn,1,1
If Not oRs.Eof Then
	Do While Not oRs.Eof
%>
  
  <tr bgcolor="#FFFFFF">
    <td><div align="center"><a href="<%=oRs("F_SiteAdd")%>" target="_blank"><%=oRs("F_SiteName")%></a></div></td>
    <td><div align="center">
	<%
	If oRs("F_LinkType")<>2 Then
	%>
	<a href="<%=oRs("F_SiteAdd")%>" target="_blank"><img src="<%=oRs("F_SiteLogo")%>" border=0 width=88 height=31 alt="<%=oRs("F_SiteName")%>"></a>
	<%
	End If
	%>
	</div></td>
    <td><div align="center">
	<%
	If oRs("F_LinkType")=1 Then
		Response.Write "图标链接"
	ElseIf  oRs("F_LinkType")=2 Then
		Response.Write "文字链接"
	ElseIf  oRs("F_LinkType")=3 Then
		Response.Write "合作网站"
	Else
		Response.Write "链接类型参数错误"
	End If
	%>
	</div></td>
    <td><div align="center"><%
	If oRs("F_HeadShow")=True Then
		Response.Write "<font color=#ff0000>是</font>"
	Else
		Response.Write "否"
	End If
	%></div></td>
    <td><div align="center">
	<%If F_LinkType="4" Then%>
	<a href="FriendLink.asp?Action=SCFriendLink&FriendLinkId=<%=oRs("F_ID")%>&F_Recycle=True">显示</a>
	<%Else%>
	<a href="FriendLink.asp?Action=SCFriendLink&FriendLinkId=<%=oRs("F_ID")%>&F_Recycle=False">不显示</a>
	<%End If%>
	</div></td>
    <td><div align="center"><a href="FriendLink.asp?Action=ModifyFriendLink&FriendLinkId=<%=oRs("F_ID")%>">修改</a></div></td>
    <td><div align="center"><a href="FriendLink.asp?Action=DelFriendLink&FriendLinkId=<%=oRs("F_ID")%>" onClick='return confirm_delete()'>删除</a></div></td>
  </tr>

<%
	oRs.MoveNext
	Loop
Else
%>
<tr><td colspan="7" bgcolor="#FFFFFF"><div align="center">暂无友情链接信息！</div></td></tr>
<%
End If
oRs.Close
%>
</table>


<script language="JavaScript1.2">
<!--
function confirm_delete(){
	if (confirm("你确定真的要这么做吗？")){
		return true;
	}
	return false;
}
//-->
</script>

<%
End Sub
%>

<%
Sub AddSaveFriendLink()
Dim F_SiteName,F_SiteAdd,F_SiteLogo,F_LinkType,F_HeadShow

F_SiteName=Trim(Request("SiteName"))
F_SiteAdd=Trim(Request("SiteAdd"))
F_SiteLogo=Trim(Request("SiteLogo"))
F_LinkType=Trim(Request("LinkType"))
F_HeadShow=Trim(Request("HeadShow"))


If F_SiteName="" Then
	FounDerr=True
	ErrMsg=ErrMsg&"<br><li>网站名称不能为空！</li>"
End If

If F_SiteAdd="" Then
	FounDerr=True
	ErrMsg=ErrMsg&"<br><li>网站网址不能为空！</li>"
End If

If IsNumeric(F_LinkType)=False Then
	FounDerr=True
	ErrMsg=ErrMsg&"<br><li>链接类型参数错误！</li>"
End If

If F_LinkType="" Then
	FounDerr=True
	ErrMsg=ErrMsg&"<br><li>链接类型不能为空！</li>"
End If

If F_LinkType=1 Or F_LinkType=3 Then
	If F_SiteLogo="" Then
		FounDerr=True
		ErrMsg=ErrMsg&"<br><li>网站LOGO不能为空！</li>"
	End If
End If


If FounDerr=True Then
	Exit Sub
End If

If lCase(left(F_SiteAdd,7))<>"http://" Then
	F_SiteAdd="http://"&F_SiteAdd
End If

'If lCase(left(F_SiteLogo,7))<>"http://" Then
	'F_SiteLogo="http://"&F_SiteLogo
'End If

sSql="Select * From FriendLink"
oRs.Open sSql,oConn,1,3
oRs.AddNew
oRs("F_SiteName")=F_SiteName
oRs("F_SiteAdd")=F_SiteAdd
oRs("F_SiteLogo")=F_SiteLogo
oRs("F_LinkType")=F_LinkType
oRs("F_HeadShow")=F_HeadShow
oRs.Update
oRs.Close
Response.Write "<p align=center>友情链接添加成功，3秒后自动返回友情链接审核页！<script>window.setTimeout(""location.href='FriendLink.asp?Action=FriendLinkExamine'"",3000);</script></p>"
End Sub
%>


<%
Sub ModifyFriendLink()
Dim FriendLinkId
FriendLinkId=Trim(Request("FriendLinkId"))

If FriendLinkId="" Then
	FounDerr=True
	ErrMsg=ErrMsg&"<br><li>友情链接网站ID不能为空！</li>"
End If

If IsNumeric(FriendLinkId)=False Then
	FounDerr=True
	ErrMsg=ErrMsg&"<br><li>友情链接网站ID参数错误！</li>"
End If

If FounDerr=True Then
	Exit Sub
End If

sSql="Select F_ID,F_SiteName,F_SiteAdd,F_SiteLogo,F_LinkType,F_HeadShow From FriendLink Where F_ID="&FriendLinkId
oRs.Open sSql,oConn,1,1
If oRs.Eof Then
	ErrMsg=ErrMsg&"<br><li>无此友情链接网站或已被删除！</li>"
	call WriteErrMsg()
	Response.End
Else
%>
<Script Language=JavaScript>
function doSubmit(){
	if (document.FriendLinkAppl.SiteName.value==""){
		alert("网站名称不能为空！");
		return false;
	}
	if (document.FriendLinkAppl.SiteAdd.value==""){
		alert("网站地址不能为空！");
		return false;
	}
	if (document.FriendLinkAppl.LinkType.value==1){
		if (document.FriendLinkAppl.SiteLogo.value==""){
			alert("网站LOGO不能为空！");
			return false;
		}
	}
	if (document.FriendLinkAppl.LinkType.value==3){
		if (document.FriendLinkAppl.SiteLogo.value==""){
			alert("网站LOGO不能为空！");
			return false;
		}
	}}
</Script>

<table width="100%"  border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#DEDFDE">
            <form name="FriendLinkAppl" method="post" action="FriendLink.asp?Action=ModifySaveFriendLink&FriendLinkId=<%=oRs("F_ID")%>" onsubmit="return doSubmit()">
              <tr bgcolor="#f7f7f7">
                <td colspan="2"><div align="center"><strong>友　情　链　接　修　改</strong></div></td>
              </tr>
              <tr bgcolor="#FFFFFF">
              <td width="120">网站名称：</td>
              <td><input name="SiteName" type="text" class="input_text" id="SiteName" size="50" value="<%=oRs("F_SiteName")%>"></td>
            </tr>
            <tr bgcolor="#FFFFFF">
              <td width="120">网站地址：</td>
              <td><input name="SiteAdd" type="text" class="input_text" id="SiteAdd" size="50" value="<%=oRs("F_SiteAdd")%>"></td>
            </tr>
            <tr bgcolor="#FFFFFF">
              <td width="120">网站LOGO：</td>
              <td><input name="SiteLogo" type="text" class="input_text" id="SiteLogo" size="50" value="<%=oRs("F_SiteLogo")%>"></td>
            </tr>
            <tr bgcolor="#FFFFFF">
              <td width="120">链接类型：</td>
              <td><select name="LinkType" class="input_text" id="LinkType">
                <option value="1" <%If oRs("F_LinkType")=1 Then%>selected<%End If%>>图标链接</option>
                <option value="2" <%If oRs("F_LinkType")=2 Then%>selected<%End If%>>文字链接</option>
                <option value="3" <%If oRs("F_LinkType")=3 Then%>selected<%End If%>>合作网站</option>
              </select></td>
            </tr>
            <tr bgcolor="#FFFFFF">
              <td>首页显示：</td>
              <td><input name="HeadShow" type="radio" value="False"<%If oRs("F_HeadShow")=False Then%> checked="checked"<%End If%> />
                否
                <input type="radio" name="HeadShow" value="True"<%If oRs("F_HeadShow")=True Then%> checked="checked"<%End If%> />
                是</td>
            </tr>
            <tr bgcolor="#FFFFFF">
              <td colspan="2"><div align="center">
                <input type="submit" name="Submit" value=" 提 交 " class="input_submit">
               　  
               <input type="reset" name="Submit" value=" 重 置 " class="input_submit">
</div></td>
            </tr></form>
</table>

<%
End If
oRs.Close
End Sub
%>


<%
Sub ModifySaveFriendLink()

Dim FriendLinkId,F_SiteName,F_SiteAdd,F_SiteLogo,F_LinkType,F_HeadShow

FriendLinkId=Trim(Request("FriendLinkId"))
F_SiteName=Trim(Request("SiteName"))
F_SiteAdd=Trim(Request("SiteAdd"))
F_SiteLogo=Trim(Request("SiteLogo"))
F_LinkType=Trim(Request("LinkType"))
F_HeadShow=Trim(Request("HeadShow"))


If FriendLinkId="" Then
	FounDerr=True
	ErrMsg=ErrMsg&"<br><li>友情链接网站ID不能为空！</li>"
End If

If IsNumeric(FriendLinkId)=False Then
	FounDerr=True
	ErrMsg=ErrMsg&"<br><li>友情链接网站ID参数错误！</li>"
End If

If F_SiteName="" Then
	FounDerr=True
	ErrMsg=ErrMsg&"<br><li>网站名称不能为空！</li>"
End If

If F_SiteAdd="" Then
	FounDerr=True
	ErrMsg=ErrMsg&"<br><li>网站网址不能为空！</li>"
End If


If IsNumeric(F_LinkType)=False Then
	FounDerr=True
	ErrMsg=ErrMsg&"<br><li>链接类型参数错误！</li>"
End If

If F_LinkType="" Then
	FounDerr=True
	ErrMsg=ErrMsg&"<br><li>链接类型不能为空！</li>"
End If

If F_LinkType="1" Or F_LinkType="3" Then
	If F_SiteLogo="" Then
		FounDerr=True
		ErrMsg=ErrMsg&"<br><li>网站LOGO不能为空！</li>"
	End If
End If


If FounDerr=True Then
	Exit Sub
End If

If lCase(left(F_SiteAdd,7))<>"http://" Then
	F_SiteAdd="http://"&F_SiteAdd
End If

'If lCase(left(F_SiteLogo,7))<>"http://" Then
	'F_SiteLogo="http://"&F_SiteLogo
'End If

sSql="Select F_ID,F_SiteName,F_SiteAdd,F_SiteLogo,F_LinkType,F_HeadShow From FriendLink Where F_ID="&FriendLinkId
oRs.Open sSql,oConn,1,3
If Not oRs.Eof Then
	oRs("F_SiteName")=F_SiteName
	oRs("F_SiteAdd")=F_SiteAdd
	oRs("F_SiteLogo")=F_SiteLogo
	oRs("F_LinkType")=F_LinkType
	oRs("F_HeadShow")=F_HeadShow
	oRs.Update
Else
	ErrMsg=ErrMsg&"<br><li>无此友情链接网站或已被删除！</li>"
	call WriteErrMsg()
	Response.End
End If
oRs.Close
Response.Write "<p align=center>友情链接修改成功，3秒后自动返回友情链接管理页！<script>window.setTimeout(""location.href='FriendLink.asp?Action=FriendLinkManage'"",3000);</script></p>"


End Sub
%>


<%

Sub SCFriendLink
Dim FriendLinkId,F_Recycle

FriendLinkId=Trim(Request("FriendLinkId"))
F_Recycle=Trim(Request("F_Recycle"))

If FriendLinkId="" Then
	FounDerr=True
	ErrMsg=ErrMsg&"<br><li>友情链接网站ID不能为空！</li>"
End If

If IsNumeric(FriendLinkId)=False Then
	FounDerr=True
	ErrMsg=ErrMsg&"<br><li>友情链接网站ID参数错误！</li>"
End If

If F_Recycle<>"True" Then
	If F_Recycle<>"False" Then
		FounDerr=True
		ErrMsg=ErrMsg&"<br><li>参数错误！</li>"
	End If
End If

If FounDerr=True Then
	Exit Sub
End If

Set oRs=oConn.Execute("Select F_ID From FriendLink Where F_ID="&FriendLinkId)
If Not oRs.Eof Then
	sSql="Update FriendLink Set F_Recycle="&F_Recycle&" Where F_ID="&FriendLinkId
	oConn.Execute sSql
	Response.Write "<p align=center>友情链接修改成功，3秒后自动返回友情链接管理页！<script>window.setTimeout(""location.href='FriendLink.asp?Action=FriendLinkManage'"",3000);</script></p>"
Else
	ErrMsg=ErrMsg&"<br><li>无此友情链接网站或已被删除！</li>"
	call WriteErrMsg()
	Response.End
End If

oRs.Close

End Sub
%>


<%
Sub FriendLinkExamine()
%>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#DEDFDE">
  <tr bgcolor="#f7f7f7">
    <td><div align="center"><strong>网站名称</strong></div></td>
    <td><div align="center"><strong>网站LOGO</strong></div></td>
    <td><div align="center"><strong>链接类型</strong></div></td>
    <td><div align="center"><strong>审核</strong></div></td>
    <td><div align="center"><strong>删除</strong></div></td>
  </tr>

<%
sSql="Select F_ID,F_SiteName,F_SiteAdd,F_SiteLogo,F_LinkType From FriendLink Where F_Recycle=False And F_ExamMark=False Order By F_ID Desc"
oRs.Open sSql,oConn,1,1
If Not oRs.Eof Then
	Do While Not oRs.Eof
%>
  
  <tr bgcolor="#FFFFFF">
    <td><div align="center"><a href="<%=oRs("F_SiteAdd")%>" target="_blank"><%=oRs("F_SiteName")%></a></div></td>
    <td><div align="center"><a href="<%=oRs("F_SiteAdd")%>" target="_blank">
      <%
	If oRs("F_LinkType")<>2 Then
	%>
      <img src="<%=oRs("F_SiteLogo")%>" border=0 width=88 height=31 alt="<%=oRs("F_SiteName")%>"></a>
        <%
	End If
	%>
    </div></td>
    <td><div align="center">
	<%
	If oRs("F_LinkType")=1 Then
		Response.Write "图标链接"
	ElseIf  oRs("F_LinkType")=2 Then
		Response.Write "文字链接"
	ElseIf  oRs("F_LinkType")=3 Then
		Response.Write "合作网站"
	Else
		Response.Write "链接类型参数错误"
	End If
	%>
	</div></td>
    <td><div align="center"><a href="FriendLink.asp?Action=PassFriendLinkManage&FriendLinkId=<%=oRs("F_ID")%>">通过审核</a></div></td>
    <td><div align="center"><a href="FriendLink.asp?Action=DelFriendLink&FriendLinkId=<%=oRs("F_ID")%>" onClick='return confirm_delete()'>删除</a></div></td>
  </tr>

<%
	oRs.MoveNext
	Loop
Else
%>
<tr><td colspan="5" bgcolor="#FFFFFF"><div align="center">暂无待审友情链接信息！</div></td></tr>
<%
End If
oRs.Close
%>
  
</table>


<script language="JavaScript1.2">
<!--
function confirm_delete(){
	if (confirm("你确定真的要这么做吗？")){
		return true;
	}
	return false;
}
//-->
</script>

<%
End Sub
%>



<%
Sub PassFriendLinkManage()

Dim FriendLinkId
FriendLinkId=Trim(Request("FriendLinkId"))

If FriendLinkId="" Then
	FounDerr=True
	ErrMsg=ErrMsg&"<br><li>友情链接网站ID不能为空！</li>"
End If

If IsNumeric(FriendLinkId)=False Then
	FounDerr=True
	ErrMsg=ErrMsg&"<br><li>友情链接网站ID参数错误！</li>"
End If

If FounDerr=True Then
	Exit Sub
End If

Set oRs=oConn.Execute("Select F_ID From FriendLink Where F_ID="&FriendLinkId)
If Not oRs.Eof Then
	sSql="Update FriendLink Set F_Recycle=True,F_ExamMark=True Where F_ID="&FriendLinkId
	oConn.Execute sSql
	Response.Write "<p align=center>友情链接审核成功，3秒后自动返回友情链接审核页！<script>window.setTimeout(""location.href='FriendLink.asp?Action=FriendLinkExamine'"",3000);</script></p>"
Else
	ErrMsg=ErrMsg&"<br><li>无此友情链接网站或已被删除！</li>"
	call WriteErrMsg()
	Response.End
End If

oRs.Close

End Sub
%>


<%
Sub DelFriendLink()

Dim FriendLinkId
FriendLinkId=Trim(Request("FriendLinkId"))

If FriendLinkId="" Then
	FounDerr=True
	ErrMsg=ErrMsg&"<br><li>友情链接网站ID不能为空！</li>"
End If

If IsNumeric(FriendLinkId)=False Then
	FounDerr=True
	ErrMsg=ErrMsg&"<br><li>友情链接网站ID参数错误！</li>"
End If

If FounDerr=True Then
	Exit Sub
End If

Set oRs=oConn.Execute("Select F_ID From FriendLink Where F_ID="&FriendLinkId)
If Not oRs.Eof Then
	sSql="Delete From FriendLink Where F_ID="&FriendLinkId
	oConn.Execute sSql
	Response.Write "<p align=center>友情链接网站删除成功，3秒后自动返回友情链接管理页！<script>window.setTimeout(""location.href='FriendLink.asp?Action=FriendLinkManage'"",3000);</script></p>"
Else
	ErrMsg=ErrMsg&"<br><li>无此友情链接网站或已被删除！</li>"
	call WriteErrMsg()
	Response.End
End If
oRs.Close

End Sub
%> 

