<!--#include file="template.asp"-->
<!--#include file="template1.asp"-->
<!--#include file="md5.asp"-->
<%
'容错
On Error Resume Next
'----数据库设置-------------------------------
bbstable="bbs"                    '主题帖子数据表
rebbstable="rebbs"                '回复帖子数据表
boardtable="bbsboard"             '贴吧分类数据表
usertable="bbsuser"               '用户数据表
dreamsundb ="azxcs/#ddptieba.asp" '数据库路径
linktable = "friendlink"          '友情链接数据表
webname="tieba"                   '用户设置站点名称，若同一个服务器安装多个贴把，请修改此参数
conn_db_way="2"                   '数据库连接方式


Dim conn   
Dim connstr
'两种连接Access数据库的方式，3是连接sql的方式。
Select Case conn_db_way
	Case "1"
		'两种连接Access数据库的方式，建议选择ADO模式，即：2。
		'ODBC
		connstr="DBQ="+server.mappath(""&dreamsundb&"")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
	Case "2"
		'OleDb
		connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(""&dreamsundb&"")
	Case "3"
		connstr="Driver={SQL Server};Server=(local);Database=DDPTieBa;Uid=ddptieba;Pwd=ddptieba123;"
End Select

Set conn=server.createobject("ADODB.CONNECTION")
conn.open connstr
'========================================================================
'缓存变量
'========================================================================
If Application(webname&"Loaded")="" Then
Dim TieBa_Infos
'--------------写入基本信息缓存------------------
		Dim log_Infos
		SQL="select top 1 first_money,add_money,re_money,del_money,good_money,"& _
		"currentUserColor,boardManagerColor,superManagerColor,indexnum,bbsnum,"& _
		"hothits,hotrehits,posttime,isup,boardtr,"& _
		"bbsname,bbsurl,bbs_about1,bbs_about,copyright,"& _
		"bbsbanzhu,guestadd,guestrev,iscallonline,zanghuaguolv,"& _
		"zanghuaguolvChar,indeximg,isuserinfo,isFeeTopic,isReTopic,"& _
		"adFilter,keepUsername,isCheck,isShowIpName,bbs_about_gaps,bbs_about_top,sys_close,maxOnline" & _
		" from config"
		Set log_Infos=Conn.Execute(SQL)
		SQLQueryNums=SQLQueryNums+1
		TieBa_Infos=log_Infos.GetRows()
		Set log_Infos=nothing
		Application.Lock
		Application(webname&"_TieBa_Infos")=TieBa_Infos
		Application.UnLock
	'--------------写入分类信息缓存------------------
	 Dim Arr_Category,log_Category
		 SQL="SELECT board_name,board_id,board_about,board_admin FROM "&boardtable&"  ORDER BY board_order DESC,board_id DESC"
		 Set log_Category=Conn.Execute(SQL)
		 SQLQueryNums=SQLQueryNums+1
		 if log_Category.eof or log_Category.bof then
			  ReDim Arr_Category(0,0)
		 else
			  Arr_Category=log_Category.GetRows()
		 end if
		 Set log_Category=Nothing
		 Application.Lock
		 Application(webname&"_TieBa_Category")=Arr_Category
		 Application.UnLock

	Application.Lock
	Application(webname&"Loaded")="YES"
	Application.Unlock
	app="Executing"
Else 
	app="Achieved"
End If

	'--------------读取基本信息缓存------------------
Arr_Category=Application(webname&"_TieBa_Category")
TieBa_Infos=Application(webname&"_TieBa_Infos")
	
	first_money=int(TieBa_Infos(0,0)) '注册初始论坛分数
	add_money=int(TieBa_Infos(1,0)) '发布文章分数
	re_money=int(TieBa_Infos(2,0)) '回复文章分数
	del_money=int(TieBa_Infos(3,0)) '删除文章分数
	good_money=int(TieBa_Infos(4,0))'文章被推荐分数

	currentUserColor = TieBa_Infos(5,0)  '当前用户颜色
	boardManagerColor= TieBa_Infos(6,0)  '分版主颜色
	superManagerColor= TieBa_Infos(7,0) '最高管理员颜色
	indexnum = int(TieBa_Infos(8,0)) '首页每页显示条数
	bbsnum = int(TieBa_Infos(9,0)) '帖子每页显示条数

	hothits = int(TieBa_Infos(10,0)) '阅读数达到多少红色显示
	hotrehits = int(TieBa_Infos(11,0)) '回复数达到多少红色显示
	posttime = int(TieBa_Infos(12,0)) '发帖防止灌水时间，单位：秒
	isup=int(TieBa_Infos(13,0)) '回复后是否升起
	boardtr=int(TieBa_Infos(14,0)) '分类列表，几个分类自动换行

	bbsname = TieBa_Infos(15,0) '网站名称
	bbsurl=TieBa_Infos(16,0)'bbsurl
	bbs_about1 = TieBa_Infos(17,0) '贴吧广告
	bbs_about=TieBa_Infos(18,0) '贴吧广告
	copyright=TieBa_Infos(19,0) '版权设置

	bbsbanzhu = TieBa_Infos(20,0) '版主.多个版主请用|分割。
	guestadd=int(TieBa_Infos(21,0)) '游客是否可以发贴
	guestrev=int(TieBa_Infos(22,0)) '游客是否可以回复
	iscallonline=int(TieBa_Infos(23,0))'是否显示在线列表

	zanghuaguolv=TieBa_Infos(24,0)'脏话过滤[标题和内容]
	zanghuaguolvChar=TieBa_Infos(25,0) '脏话被替换成的字符
	indeximg=TieBa_Infos(26,0)
	isuserinfo=int(TieBa_Infos(27,0))'必须登陆才能察看用户信息．1是任何人可以看，0为登陆察看。
	isFeeTopic = int(TieBa_Infos(28,0))'能否发布花积分看帖的主题 0:普通可发,1:管理员及超管，2:超管
	isReTopic = int(TieBa_Infos(29,0))'是否允许发表禁止回复的帖子 0,普通人；1,管理员及超管；2,超管

	adFilter = TieBa_Infos(30,0)'广告过滤
	keepUsername = TieBa_Infos(31,0)'被保留的用户名
	isCheck = int(TieBa_Infos(32,0))'0:默认放开帖子 1:默认屏蔽帖子
	isShowIpName = int(TieBa_Infos(33,0))'0:不显示IP的详细位置 1:按91webs显示 2:按纯真数据库进行显示(均来自于外部数据)
	bbs_about_gaps = TieBa_Infos(34,0)'帖间广告
	bbs_about_top = TieBa_Infos(35,0)'顶部广告
	sys_close = TieBa_Infos(36,0)'系统是否关闭 0,开放；1，关闭； + 关闭原因
	maxOnline = TieBa_Infos(37,0)'最大支持的在线人数
	ispicurl=1'是否启用主图浏览功能。
	multiLevelCategory = 1

	' 以下三个字段可更改
	TieBa_version="1.5.0 Access" '当前版本号
	TieBa_UpdateDate="2008-4-10" '最新更新时间
	TieBa_Index_Title="吉林信息网"  'Index.asp 和 Default.asp 页面的标题内容


'判断用户是否登陆
temp_user=Request.Cookies("DreamSun_Post_"&webname)("username")
temp_rnd=Request.Cookies("DreamSun_Post_"&webname)("rnd")
If temp_user<>"" And temp_rnd<>"" Then 
temp_rndduan=Left(md5(temp_rnd),5)&right(md5(temp_rnd),5)
	set rs=conn.execute("select cookrnd from "& UserTable &" where username='"&temp_user&"'",0,0)
			if not rs.eof then temp_user_rnd=rs(0)
		rs.close
	set rs=Nothing
		If temp_user_rnd=temp_rndduan Then 
			Dreamsun_name=temp_user
		Else
			Dreamsun_name=""
		End If 
End If 


'防止SQL注入代码
Dim Fy_Url,Fy_a,Fy_x,Fy_Cs(),Fy_Cl,Fy_Ts,Fy_Zx
Fy_Url=Request.ServerVariables("QUERY_STRING")
Fy_a=split(Fy_Url,"&")
redim Fy_Cs(ubound(Fy_a))
for Fy_x=0 to ubound(Fy_a)
Fy_Cs(Fy_x) = left(Fy_a(Fy_x),instr(Fy_a(Fy_x),"=")-1)
Next
For Fy_x=0 to ubound(Fy_Cs)
If Fy_Cs(Fy_x)<>"" Then
If Instr(LCase(Request(Fy_Cs(Fy_x))),"'")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),"and ")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),"select ")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),"update ")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x)))," chr")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),"delete%20from")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),";")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),"insert")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),"mid")<>0 Or Instr(LCase(Request(Fy_Cs(Fy_x))),"master.")<>0 Then
Response.Write "<Script Language=JavaScript>alert(' 您输入的参数不合法');window.close();</Script>"
Response.End
End If
End If
Next

'容错
If Err.Number<>0 Then
	Response.Write("System Init Error,Please Contact With Webmaster. " & FormatDateTime(now(),2))
	Response.Write("<p>describ:"&err.Description)
	On Error GoTo 0
	Response.End()
End If
%>

