<!--#include file="const.asp" -->
<%
	response.buffer = true

	dim startTime, endtime
	startTime = timer()


	dim conn
	dim connstr
	dim rs, rSub
	dim sql

	connstr = "driver={SQL Server};server=(local);UID=jndiy;PWD=dsk03KAS^%87;database=jndiy"
	set conn = server.createobject("ADODB.CONNECTION")

	if err.number<>0 then
		err.clear
		set conn=nothing
		response.write "<script>window.status=""创建 ADO 对象失败"";</script>"
		response.end
	else
		conn.open connstr

		if err.number<>0 then
			err.clear
			set conn=nothing
			response.write "<script>window.status=""SQL Server 数据库连接失败"";</script>"
					'''请检查数据库是否存在，以及 ODBC 是否存在
			response.end
		end if
	end if
 
	set rs = Server.CreateObject("ADODB.Recordset")     '主程序用
	set rSub = Server.CreateObject("ADODB.Recordset")   '子程序用



	'server=为服务器名，请修改为你主机中SQL的服务器名
	'uid=为用户名，请修改为你在SQL的用户名
	'pwd=为密码，请修改为你在SQL的用户的密码如没设密码应为
	'database=为你在SQL使用的数据库名，请修改为你在SQL在的使用数据库名

'+++++++++++++++++++++++++++++++上面这段为用户登录后要记录的COOKIES+++++++++++++++++++++++++++


	Sub objend()
		set rSub=nothing
		set rs=nothing
		conn.close
		set conn=nothing

		endtime=timer()
		response.write "<script>window.status=""执行时间：" &_
				FormatNumber((endtime-startTime)*1000,3) & " 毫秒"";" &_
				"setTimeout(""window.status='';"",2000);" &_
				"</script>"
	End Sub
	
		
	'函数功能：获取网站指定属性
	Function GetKey(strKeyName,strUserID,strType)
		strSQL="Select k_value From attrib Where m_id=" & strUserID & " And k_name='" & strKeyName & "' And k_type='" & strType & "'"
		set rsKey=Server.CreateObject("ADODB.RecordSet")
		rsKey.open strSQL,conn,1,1
		if rsKey.recordcount > 0 then
			GetKey=trim(rsKey("k_value"))
		else
			GetKey="Null"
		end if
	End Function
	
	'函数功能：设置网站指定属性
	Function SetKey(strKeyName,strKeyValue,strUserID,strType)
		strSQL="Select k_value From attrib Where m_id=" & strUserID & " And k_name='" & strKeyName & "' And k_type='" & strType & "'"
		set rsKey=Server.CreateObject("ADODB.RecordSet")
		rsKey.open strSQL,conn,1,1
		if rsKey.recordcount > 0 then
			'如果属性已在，则修改
			strSQL="Update attrib Set k_value='" & strKeyValue & "' Where m_id=" & strUserID & " And k_name='" & strKeyName & "' And k_type='" & strType & "'"
		else
			'如果不存在，则创建
			strSQL="Insert Into attrib(m_id,k_type, k_name, k_value) Values(" & strUserID & ",'" & strType & "','" & strKeyName & "', '" & strKeyValue & "')"
		end if
		conn.execute strSQL,0,1
	End Function

	'获取文件所在的用户名称
	Function GetUserName()
		'Get CurrFolder Name,too The user name
		CurrPath=Server.MapPath( "../")
		pt=InStrRev(CurrPath,"\")
		CurrFolder=Right(CurrPath,len(CurrPath)-pt)
		GetUserName=CurrFolder
	End Function
	
	'检查用户权限	
	sub checkuser(limitnum)
		userlimits=trim(Session("AdminLimit"))
		lp=instr(userlimits,limitnum)
		if lp<=0 then
			response.Redirect("../Error.asp?msg=对不起，您无权访问这个页面，有问题请与管理员联系！")
			response.end
		end if
	end sub
	
	'提示系统信息
	sub ShowMsg(msg)
		msg=server.URLEncode(msg)		'将字符串编码，以便做参数传递
		response.Redirect("../admin/error.asp?msg=" + msg)
	end sub
			


'===========================专门用来过滤Request的参数值===================================			
function GetVariable(strVariableName)
	if IsEmpty(Request(strVariableName)) then
		GetVariable=empty
		exit Function
	end if
	GetVariable=Replace(Request(strVariableName),"'","''")
	GetVariable=Replace(GetVariable,";","")
	GetVariable=Replace(GetVariable,"--","")
end function
	

function GetFormVariable(strVariableName)
	if IsEmpty(Request.Form(strVariableName)) then
		GetFormVariable=empty
		exit Function
	end if
	GetFormVariable=Replace(Request.Form(strVariableName),"'","''")
	GetFormVariable=Replace(GetFormVariable,"--","")
end function
	
function GetQueryString(strVariableName)
	if IsEmpty(Request.QueryString(strVariableName)) then
		GetQueryString=empty
		exit Function
	end if
	GetQueryString=Replace(Request.QueryString(strVariableName),"'","''")
	GetQueryString=Replace(GetQueryString,";","")
	GetQueryString=Replace(GetQueryString,"--","")
end function

'===========================专门用来过滤Request的参数值===================================			
%>
