<!--#include file="mdb.asp"-->
<%
if session("User")="" then
	response.write"<SCRIPT language=JavaScript>alert('您尚未登录！');"
	response.write"location.href=""sd_admin_login.asp"";</SCRIPT>"
end if
	webid=request.form("id")
	userid=request.form("userid")
	if trim(webid)="" or userid="" then
		Response.Write ("<script language=javascript>alert('无法获得相关ID！');history.back(-1);</script>")
		response.end
	end if
top_day=request.form("sd_zt")
sql="select * from [sd_user] where sd_userid="& userid
rs.open sql,conn,1,3 
if not (rs.eof and rs.bof) then
	sd_Points=rs("sd_Points")
	if sd_Points>cint(top_day)*20 then
		set rs1=server.CreateObject("adodb.recordset")
		sql1="select * from [sd_web] sd_id="& sd_id
		rs1.open sql1,conn,1,3 
		if not (rs1.eof and rs1.bof) then
			if DateDiff("d",now(),CDate(rs1("sd_TopEndTime")))<0 then
				rs1("sd_TopEndTime")=DateAdd("d",cint(top_day),NOW())
			else
				rs1("sd_TopEndTime")=DateAdd("d",cint(top_day),CDate(rs1("sd_TopEndTime")))
			end if
				rs1("sd_Top")="1"
			rs1.update
			rs1.close
			set rs1=nothing
		else
			rs1.close
			set rs1=nothing
			Response.Write ("<script language=javascript>alert('没有找到相关ID记录！');this.location.href='sd_weblist.asp';</script>")
			response.end
		end if
		rs("sd_Points")=rs("sd_Points")-cint(top_day)*20
		session("Points")=rs("sd_Points")
		rs.update
		rs.close
		set rs=nothing
		Response.Write ("<script language=javascript>alert('友情链接置顶成功！');this.location.href='sd_weblist.asp';</script>")
		response.end
	ELSE
		rs.close
		set rs=nothing
		Response.Write ("<script language=javascript>alert('金币不够！不能友情链接置顶！');this.location.href='sd_weblist.asp';</script>")
		response.end
	END IF
END IF
%>