<%@ LANGUAGE = VBScript CodePage = 936%>
<%
Option Explicit
Response.Buffer = True
Dim Startime
dim ConnStr,conn
dim cache
dim cookiesname
Startime = Timer()
cookiesname = "teacher" 'cookies名称
const cachename="teacher" '缓存对象前缀名
const issqldate=false
if not issqldate then
	Dim Db
	'access数据库连接参数：第一次使用请修改本处数据库地址并相应修改data目录中数据库名称，如将oblog2.mdb修改为oblog2.asp
	Db = "/#yan163-date#/blog.asa"
	ConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(db)
else
	'sql数据库连接参数：数据库名、用户密码、用户名、连接名（本地用local，外地用IP）
	Dim SqlDatabaseName,SqlPassword,SqlUsername,SqlLocalName
	SqlDatabaseName = "oblog"
	SqlPassword = "oblog"
	SqlUsername = "oblog"
	SqlLocalName = "(local)"
	ConnStr = "Provider = Sqloledb; User ID = " & SqlUsername & "; Password = " & SqlPassword & "; Initial Catalog = " & SqlDatabaseName & "; Data Source = " & SqlLocalName & ";"
end if
'On Error Resume Next
Set conn = Server.CreateObject("ADODB.Connection")
conn.open ConnStr

If Err Then
	err.Clear
	Set Conn = Nothing
	Response.Write "数据库连接出错，请检查连接字串。"
	Response.End
End If

if isarray(application(cachename&"info"))=false then
	call PutApplicationValue()
end if
'call PutApplicationValue()
sub closeconn()
	conn.close
	set conn=nothing
end sub

sub PutApplicationValue()
	dim  infosql,rsinfo
	infosql="select show_log_num,enguestcomment,site_keyword,needclassid,sitefriends,"
	infosql=infosql&"blogcheck,copyrighturl,siteurl,siterefu_num,sitetitle,webmasteremail,"
	infosql=infosql&"logcount,getlog_num,EnableUserReg,logcount,commentcount,messagecount,usercount,timediff,"
	infosql=infosql&"sitename,show_imgw_num,show_img_mouse,blog_showruntime,blog_showrefu,vip_prosee,show_listuser_num,"
	infosql=infosql&"blog_profilt,show_comment_asc,userlink_add,user_sendword,siteplacard,smalledit,gourl"
	infosql=infosql&" from bloginfo"
	set rsinfo=conn.execute(infosql)
	Redim ApplicationValue(32)
	dim i
	for i=0 to 32
		ApplicationValue(i)=rsinfo(i)
	next
	set rsinfo=nothing
	Application.Lock
	set Application(cachename&"info")=nothing
	Application(cachename&"info")=ApplicationValue
	Application(cachename&"index_update")=true
	Application(cachename&"list_update")=true
	Application.unlock
end sub

const ot_user=true '是否使用其他数据库用户表,true为使用，false为不使用
if ot_user then '若使用外部数据库表请自行修改下面的变量值
	dim ot_connstr,ot_conn,ot_usertable,ot_username,ot_password,ot_regurl,ot_lostpasswordurl
	ot_connstr= "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath("/#yan163-date#/#yan163#date.asp") '外部数据库连接字符串
	Set ot_conn = Server.CreateObject("ADODB.Connection")
	ot_conn.open ot_connStr '外部数据库连接
	ot_usertable="user_data" '用户表名
	ot_username="username" '用户名字段
	ot_password="password" '密码字段
	ot_regurl="/register.asp" '注册用户链接
	ot_lostpasswordurl="/lostpass.asp" '找回密码链接	
end if
%>
<%
On Error Resume Next
Dim strTemp,hk
If Trim(Request.QueryString) <> "" Then strTemp =Trim(Request.QueryString)

strTemp = LCase(strTemp)
hk=0
If Instr(strTemp,"count(")<>0 then hk=1
If Instr(strTemp,"asc(")<>0 then hk=1
If Instr(strTemp,"mid(")<>0 then hk=1
If Instr(strTemp,"char(")<>0 then hk=1
If Instr(strTemp,"xp_cmdshell")<>0 then hk=1
If Instr(strTemp,"'")<>0 then hk=1
if hk=1 then
Response.Write "<script language='javascript'>"
Response.Write "alert('大虾,你搞什么啊？');"
Response.Write "location.href='javascript:history.back()';"
Response.Write "</script>"
response.end
hk=0
End If
%>