<%
Class cls_TeGqMain
	Dim WebName, WebUrl, Renovates, Copyright, IndexGame, Webmaster ,xzip,ifopen,zfb1,zfb2,zfb3,zfb4
	Dim sfUlock, JzUlock, sfLook, mirsfID, mirsfday, sf_hot, sf_top
	Dim bg_1, bg_2, bg_3, bg_4,bg_5, bg_6, bg_7, bg_8, bg_1_1, bg_2_2, bg_3_3, bg_4_4, bg_5_5, bg_6_6, bg_7_7, bg_8_8, IsNews
	Dim sfhits, hottime_1, hottime_2, finePage, TabWidth,ShowHtml, ServerDir
	Dim MaxPerPage, AdminPage, ssign, WebKeywords, GetUserip, sfIsUlock, jzIsUlock
	Dim Indexsf0, Indexsf1, Indexsf2, Indexsf3, Indexsf4, Indexsf5, SiteVersion, rs3, i
	Dim zx_11, zx_22, zx_33, zx_44, zx_55, zx_66, zx_77, zx_88, zx_99, zx_10, zx_101, zx_102
	'================================================
	'作  用：页面顶部
	'================================================
	        Public Function Head()
			dim rs2
				set rs2=conn.execute("select ifopen , xzip from gq_config")
		if rs2("ifopen")=0 then 
			response.write "网站正在维护，请稍候访问"
			response.end
		end if
		
		if instr(rs2("xzip"),request.ServerVariables("REMOTE_ADDR"))>0 then 
			response.write "你的IP被限制访问，请重新尝试"
			response.end
		end if
		Response.Write "<html>" & vbCrLf
		Response.Write "<HEAD>" & vbCrLf
		Response.Write "<title>" & start & "," & webname & "</title>" & vbCrLf
		Response.Write "<meta http-equiv=""Content-Type"" content=""text/html; charset=gb2312"">" & vbCrLf
		Response.Write "<META NAME=""keywords"" CONTENT=""" & WebKeywords & """>" & vbCrLf
		Response.Write "<META NAME=""description"" CONTENT=""" & start & ","& Renovates & """>" & vbCrLf
		Response.Write "<META name=""AUTHOR"" content=""" & webname & """>" & vbCrLf
		Response.Write "<link rel='stylesheet' href='/images/style.css' type='text/css'>" & vbCrLf
		Response.Write "</HEAD>" & vbCrLf
		Response.Write "<BODY>" & vbCrLf
%>
<!--#include file="../adminqwe/config_money.asp"-->
<!--#include file="top.asp"-->
<%End Function
	'================================================
	'作  用：页面低部
	'================================================
         Public Function Footer()
		%>
<table width="1003" height="82" border="0" align="center" cellpadding="0" cellspacing="0" class=text_foot>
              <tr>
                <td width="100%" background="/images/QiKuCMS_foot.jpg" class=text_foot align="center">
<%=Copyright%>
<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?2c16f992adc430c8bf6ccc9489b497dd";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>

	<%End Function
	'================================================
	'作  用：防注入
	'================================================
	Public Function CheckInfuse(ByVal str, ByVal strLen)
		Dim strUnsafe, arrUnsafe
		Dim i
		If Trim(str) = "" Then
			CheckInfuse = ""
			Exit Function
		End If
		str = Left(str, strLen)
		On Error Resume Next
		strUnsafe = "'|^|;|and|exec|insert|select|delete|update|count|*|%|chr|mid|master|truncate|char|declare"
		If Trim(str) <> "" Then
			If Len(str) > strLen Then
				Response.Write "<Script Language=JavaScript>alert('安全系统提示↓\n\n您提交的字符数超过了限制！');history.back(-1)</Script>"
				CheckInfuse = ""
				Response.End
			End If
			arrUnsafe = Split(strUnsafe, "|")
			For i = 0 To UBound(arrUnsafe)
				If InStr(1, str, arrUnsafe(i), 1) > 0 Then
					Response.Write "<Script Language=JavaScript>alert('安全系统提示↓\n\n请不要在参数中包含非法字符！');history.back(-1)</Script>"
					CheckInfuse = ""
					Response.End
				End If
			Next
		End If
		CheckInfuse = Trim(str)
		Exit Function
		If Err.Number <> 0 Then
			Err.Clear
			Response.Write "<Script Language=JavaScript>alert('安全系统提示↓\n\n请不要在参数中包含非法字符！');history.back(-1)</Script>"
			CheckInfuse = ""
			Response.End
		End If
	End Function
	Public Sub PreventInfuse()
		On Error Resume Next
		Dim SQL_Nonlicet, arrNonlicet
		Dim PostRefer, GetRefer, Sql_DATA
		SQL_Nonlicet = "'|;|^|and|exec|insert|select|delete|update|count|*|%|chr|mid|master|truncate|char|declare"
		arrNonlicet = Split(SQL_Nonlicet, "|")
		If Request.Form <> "" Then
			For Each PostRefer In Request.Form
				For Sql_DATA = 0 To UBound(arrNonlicet)
					If InStr(1, Request.Form(PostRefer), arrNonlicet(Sql_DATA), 1) > 0 Then
						Response.Write "<Script Language=JavaScript>alert('安全系统提示↓\n\n请不要在参数中包含非法字符！');history.back(-1)</Script>"
						Response.End
					End If
				Next
			Next
		End If
		If Request.QueryString <> "" Then
			For Each GetRefer In Request.QueryString
				For Sql_DATA = 0 To UBound(arrNonlicet)
					If InStr(1, Request.QueryString(GetRefer), arrNonlicet(Sql_DATA), 1) > 0 Then
						Response.Write "<Script Language=JavaScript>alert('安全系统提示↓\n\n请不要在参数中包含非法字符！');history.back(-1)</Script>"
						Response.End
					End If
				Next
			Next
		End If
	End Sub
	'================================================
	'作  用：基本设置信息
	'================================================
	Public Function ReadConfig(ByVal SysID)
		Dim Rs, SQL
		On Error Resume Next
		Set Rs = Server.CreateObject("ADODB.Recordset")
		SQL = "SELECT * from Gq_Config Where ID=" & SysID
		Rs.Open SQL, Conn, 1, 1
		WebName = Rs("SiteName"): WebUrl = Rs("SiteUrl"): Renovates = Rs("Renovates"): Copyright = Rs("Copyright"): IndexGame = Rs("IndexGame")
		xzip=rs("xzip")
		ifopen=rs("ifopen")
'               --------------------------------------------------------------------------------------------------------------------------------------------
		Webmaster = Rs("Webmaster"): sfUlock = Rs("sfUlock"): JzUlock = Rs("JzUlock"): sfLook = Rs("sfLook"): mirsfID = Rs("mirsfID")
		zfb1=rs("zfb1"):zfb2=rs("zfb2"):zfb3=rs("zfb3"):zfb4=rs("zfb4")
'               --------------------------------------------------------------------------------------------------------------------------------------------
		mirsfday = Rs("mirsfday"): sf_hot = Rs("sf_hot"): sf_top = Rs("sf_top"): bg_1 = Rs("bg_1"): bg_2 = Rs("bg_2"): bg_3 = Rs("bg_3")
'               --------------------------------------------------------------------------------------------------------------------------------------------
		bg_4 = Rs("bg_4"): bg_5 = Rs("bg_5"):  bg_6 = Rs("bg_6"):  bg_7 = Rs("bg_7"):  bg_8 = Rs("bg_8"):  bg_1_1 = Rs("bg_1_1"): bg_2_2 = Rs("bg_2_2"): bg_3_3 = Rs("bg_3_3"): bg_4_4 = Rs("bg_4_4"): bg_5_5 = Rs("bg_5_5"):  bg_6_6 = Rs("bg_6_6"):  bg_7_7 = Rs("bg_7_7"):  bg_8_8 = Rs("bg_8_8"):  sfhits = Rs("sfhits")
'               --------------------------------------------------------------------------------------------------------------------------------------------
		hottime_1 = Rs("hottime_1"): hottime_2 = Rs("hottime_2"): finePage = Rs("finePage"): MaxPerPage = Rs("MaxPerPage"): IsNews = Rs("IsNews")
'               --------------------------------------------------------------------------------------------------------------------------------------------
		AdminPage = Rs("AdminPage"): ssign = Rs("ssign"): WebKeywords = Rs("WebKeywords"): TabWidth = Rs("TabWidth"): ShowHtml = Rs("ShowHtml")
'               --------------------------------------------------------------------------------------------------------------------------------------------
		Indexsf1 = Rs("Indexsf1"): Indexsf2 = Rs("Indexsf2"): Indexsf3 = Rs("Indexsf3"): Indexsf4 = Rs("Indexsf4"): Indexsf5 = Rs("Indexsf5") 
		GetUserip = CheckStr(getIP): ServerDir = "/": SiteVersion = Rs("SiteVersion")
		sfIsUlock=conn.execute("select count(*) from Gq_sfdata where ulock=0")(0)
		jzIsUlock=conn.execute("select count(*) from Gq_jzdata where ulock=0")(0)
		Sitesflook="open.asp?action=go&"
	End Function
	Public Function ContentHtml(ByVal strRs)
		Dim strHtmlFine, strHtmlName
		strHtmlFine = year(strRs("Sdate")) & month(strRs("Sdate")) & day(strRs("Sdate"))
		strHtmlName = ServerDir & year(strRs("Sdate")) & month(strRs("Sdate")) & day(strRs("Sdate")) & strRs("ID")
		ContentHtml = strHtmlFine & strHtmlName
	End Function
	'================================================
	'作  用：相对路径转换为绝对路径
	'================================================
	Public Function ChkMapPath(ByVal strPath)
		On Error Resume Next
		Dim fullPath
		strPath = Replace(Replace(Trim(strPath), "//", "/"), "\\", "\")
		If strPath = "" Then strPath = "."
		If InStr(strPath,":\") = 0 Then 
			fullPath = Server.MapPath(strPath)
		Else
			strPath = Replace(strPath,"/","\")
			fullPath = Trim(strPath)
			If Right(fullPath, 1) = "\" Then
				fullPath = Left(fullPath, Len(fullPath) - 1)
			End If
		End If
		ChkMapPath = fullPath
	End Function
	'================================================
	'作  用：计算天数
	'================================================
	Public Function Checkday(toptime,topday)
		If Not Isnull(toptime) Then
			If Cdate(toptime)+topday>=date Then
				Checkday=True
			Else
				Checkday=False
			End if
		Else
			Checkday=False
		End if
	End function
	'================================================
	'作  用：过滤字符
	'================================================
	Public Function CheckStr(ByVal str)
		If IsNull(str) Then
			CheckStr = ""
			Exit Function
		End If
		str = Replace(str, Chr(0), "")
		CheckStr = Replace(str, "'", "''")
	End Function
	Public Function CheckBadstr(str)
		If IsNull(str) Then
			CheckBadstr = vbNullString
			Exit Function
		End If
		str = Replace(str, Chr(0), vbNullString)
		str = Replace(str, Chr(34), vbNullString)
		str = Replace(str, "%", vbNullString)
		str = Replace(str, "@", vbNullString)
		str = Replace(str, "!", vbNullString)
		str = Replace(str, "^", vbNullString)
		str = Replace(str, "=", vbNullString)
		str = Replace(str, "--", vbNullString)
		str = Replace(str, "$", vbNullString)
		str = Replace(str, "'", vbNullString)
		str = Replace(str, ";", vbNullString)
		CheckBadstr = Trim(str)
	End Function
	Public Function ChkNumeric(ByVal CHECK_ID)
		If CHECK_ID <> "" And IsNumeric(CHECK_ID) Then
			CHECK_ID = CLng(CHECK_ID)
			If CHECK_ID < 0 Then CHECK_ID = 0
		Else
			CHECK_ID = 0
		End If
		ChkNumeric = CHECK_ID
	End Function
	'================================================
	'作  用：过滤表单字符
	'================================================
	Public Function ChkFormStr(ByVal str)
		Dim fString
		fString = str
		If IsNull(fString) Then
			ChkFormStr = ""
			Exit Function
		End If
		fString = Replace(fString, "'", "&#39;")
		fString = Replace(fString, Chr(34), "&quot;")
		fString = Replace(fString, Chr(13), "")
		fString = Replace(fString, Chr(10), "")
		fString = Replace(fString, Chr(9), "")
		fString = Replace(fString, ">", "&gt;")
		fString = Replace(fString, "<", "&lt;")
		fString = Replace(fString, "%", "％")
		ChkFormStr = Trim(JAPEncode(fString))
	End Function
	Public Function JAPEncode(ByVal str)
		Dim FobWords, i
		On Error Resume Next
		If IsNull(str) Or Trim(str) = "" Then
			JAPEncode = ""
			Exit Function
		End If
		FobWords = Array(92, 304, 305, 430, 431, 437, 438, 12460, 12461, 12462, 12463, 12464, 12465, 12466, 12467, 12468, 12469, 12470, 12471, 12472, 12473, 12474, 12475, 12476, 12477, 12478, 12479, 12480, 12481, 12482, 12483, 12485, 12486, 12487, 12488, 12489, 12490, 12496, 12497, 12498, 12499, 12500, 12501, 12502, 12503, 12504, 12505, 12506, 12507, 12508, 12509, 12510, 12521, 12532, 12533, 65340)
		For i = 1 To UBound(FobWords, 1)
			If InStr(str, ChrW(FobWords(i))) > 0 Then
				str = Replace(str, ChrW(FobWords(i)), "&#" & FobWords(i) & ";")
			End If
		Next
		JAPEncode = str
	End Function
	'================================================
	'作  用：判断连接是否来自外部
	'================================================
	Public Function CheckPost()
		On Error Resume Next
		Dim server_v1, server_v2
		CheckPost = False
		server_v1 = CStr(Request.ServerVariables("HTTP_REFERER"))
		server_v2 = CStr(Request.ServerVariables("SERVER_NAME"))
		If Mid(server_v1, 8, Len(server_v2)) = server_v2 Then
			CheckPost = True
		End If
	End Function
	'================================================
	'作  用：IP获取
	'================================================
	Public Function getIP() 
		Dim strIPAddr 
		If Request.ServerVariables("HTTP_X_FORWARDED_FOR") = "" Or InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), "unknown") > 0 Then 
			strIPAddr = Request.ServerVariables("REMOTE_ADDR") 
		ElseIf InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ",") > 0 Then 
			strIPAddr = Mid(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), 1, InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ",")-1) 
		ElseIf InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ";") > 0 Then 
			strIPAddr = Mid(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), 1, InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ";")-1)
		Else 
			strIPAddr = Request.ServerVariables("HTTP_X_FORWARDED_FOR") 
		End If 
		getIP = Replace(Trim(Mid(strIPAddr, 1, 30)), "'", "")
	End Function
	'===========================================
	'作  用：数据库连接
	'===========================================
	Public Function Execute(Command)
		If Not IsObject(conn) Then ConnectionDatabase	
		On Error Resume Next
		Set Execute = conn.Execute(Command)
		If Err Then
			If IsDeBug = 1 Then
				Response.Write "你执行的语句是：" & Command
				Response.Write "<BR>错误信息为：" & Err.description
			Else
				Response.Write "查询数据的时候发现错误，请检查您的查询代码是否正确。"
			End If
			Err.Clear
			conn.close
			set conn=nothing
			Response.End
		End If	
	End Function
	'===========================================
	'作  用：系统分配随机代码
	'===========================================
	Public Function GetRandomCode()
		Dim Ran, i, LengthNum
		LengthNum = 16
		GetRandomCode = ""
		For i = 1 To LengthNum
			Randomize
			Ran = CInt(Rnd * 2)
			Randomize
			If Ran = 0 Then
				Ran = CInt(Rnd * 25) + 97
				GetRandomCode = GetRandomCode & UCase(Chr(Ran))
			ElseIf Ran = 1 Then
				Ran = CInt(Rnd * 9)
				GetRandomCode = GetRandomCode & Ran
			ElseIf Ran = 2 Then
				Ran = CInt(Rnd * 25) + 97
				GetRandomCode = GetRandomCode & Chr(Ran)
			End If
		Next
	End Function
	'===========================================
	'作  用：通用分页
	'===========================================
	Public Function ShowListPage(CurrentPage,Pcount,totalrec,PageNum,strLink,ListName)
		With Response
			.Write "<script>"
			.Write "ShowListPage("
			.Write CurrentPage
			.Write ","
			.Write Pcount
			.Write ","
			.Write totalrec
			.Write ","
			.Write PageNum
			.Write ",'"
			.Write strLink
			.Write "','"
			.Write ListName
			.Write "');"
			.Write "</script>" & vbNewLine
		End With
	End Function
	'================================================
	'作  用：通用HTML分页
	'================================================
	Public Function ShowHtmlPage(CurrentPage,Pcount,totalrec,PageNum,strLink,ExtName,ListName)
		With Response
			.Write "<script>"
			.Write "ShowHtmlPage("
			.Write CurrentPage
			.Write ","
			.Write Pcount
			.Write ","
			.Write totalrec
			.Write ","
			.Write PageNum
			.Write ",'"
			.Write strLink
			.Write "','"
			.Write ExtName
			.Write "','"
			.Write ListName
			.Write "');"
			.Write "</script>" & vbNewLine
		End With
	End Function
	'===========================================
	'作  用：读取文件URL
	'===========================================
	Public Function ReadFileUrl(url)
		On Error Resume Next
		ReadFileUrl = ""
		If url = "" Then Exit Function
		Dim strTemp
		If CheckUrl(url) = 1 Then
			strTemp = Trim(url)
		ElseIf CheckUrl(url) = 2 Then
			strTemp = Trim(url)
		Else
			strTemp = Replace(url, "/", "")
			strTemp = Trim(ServerDir & strTemp)
		End If
		ReadFileUrl = strTemp
	End Function
	'================================================
	'作  用：读取文件内容
	'================================================
	Public Function Readfile(ByVal fromPath)
		On Error Resume Next
		Dim strTemp,fso,f
		If InStr(fromPath, ":") = 0 Then fromPath = Server.MapPath(fromPath)
		Set fso = Server.CreateObject(ServerObject(1))
		If fso.FileExists(fromPath) Then
			Set f = fso.OpenTextFile(fromPath, 1, True)
			strTemp = f.ReadAll
			f.Close
			Set f = Nothing
		End If
		Set fso = Nothing
		Readfile = strTemp
		If Err.Number <> 0 Then Err.Clear
	End Function
	'===========================================
	'作  用：创建文本文件
	'===========================================
	Public Function CreatedTextFile(ByVal fromPath, ByVal body)
		On Error Resume Next
		Dim fso,fff
		If InStr(fromPath, ":") = 0 Then fromPath = Server.MapPath(fromPath)
		Set fso = Server.CreateObject(ServerObject(1))
		Set fff = fso.OpenTextFile(fromPath, 2, True)
		fff.Write body
		fff.Close
		Set fff = Nothing
		Set fso = Nothing
		If Err.Number <> 0 Then Err.Clear
	End Function
	'===========================================
	'作  用：自动生成目录
	'===========================================
	Public Function CreatPathEx(ByVal sPath)
		sPath = Replace(sPath, "/", "\")
		sPath = Replace(sPath, "\\", "\")
		On Error Resume Next
		Dim strHostPath,strPath
		Dim sPathItem,sTempPath
		Dim i,fso
		Set fso = Server.CreateObject(ServerObject(1))
		strHostPath = Server.MapPath("/")
		If InStr(sPath, ":") = 0 Then sPath = Server.MapPath(sPath)
		If fso.FolderExists(sPath) Or Len(sPath) < 3 Then
			CreationPath = True
			Exit Function
		End If
		strPath = Replace(sPath, strHostPath, vbNullString,1,-1,1)
		sPathItem = Split(strPath, "\")
		If InStr(LCase(sPath), LCase(strHostPath)) = 0 Then
			sTempPath = sPathItem(0)
		Else
			sTempPath = strHostPath
		End If
		For i = 1 To UBound(sPathItem)
			If sPathItem(i) <> "" Then
				sTempPath = sTempPath & "\" & sPathItem(i)
				If fso.FolderExists(sTempPath) = False Then
					fso.CreateFolder sTempPath
				End If
			End If
		Next
		Set fso = Nothing
		If Err.Number <> 0 Then Err.Clear
		CreatPathEx = True
	End Function
	'================================================
	'作  用：FSO删除文件
	'================================================
	Public Function FileDelete(ByVal FilePath)
		FileDelete = False
		On Error Resume Next
		Dim fso
		Set fso = Server.CreateObject(ServerObject(1))
		If FilePath = "" Then Exit Function
		If InStr(FilePath, ":") = 0 Then FilePath = Server.MapPath(FilePath)
		If fso.FileExists(FilePath) Then
			fso.DeleteFile FilePath, True
			FileDelete = True
		End If
		Set fso = Nothing
		If Err.Number <> 0 Then Err.Clear
	End Function
	'================================================
	'作  用：过滤HTML代码
	'================================================
	Public Function HTMLEncode(ByVal fString)
		If Not IsNull(fString) Then
			fString = Replace(fString, ">", "&gt;")
			fString = Replace(fString, "<", "&lt;")
			fString = Replace(fString, Chr(32), " ")
			fString = Replace(fString, Chr(9), " ")
			fString = Replace(fString, Chr(34), "&quot;")
			fString = Replace(fString, Chr(39), "&#39;")
			fString = Replace(fString, Chr(13), "")
			fString = Replace(fString, " ", "&nbsp;")
			fString = Replace(fString, Chr(10), "<br /> ")
			fString = ChkBadWords(fString)
			HTMLEncode = fString
		End If
	End Function
	'================================================
	'作  用：判断ID是否为整数
	'================================================
	Public Function IsInteger(Para)
		On Error Resume Next
		Dim str
		Dim l,i
		If isNUll(para) then 
			isInteger=false
			Exit Function
		End If
		str=Cstr(para)
		If trim(str)="" then
			IsInteger=false
			Exit Function
		End If
		l=len(str)
		For i=1 to l
			If mid(str,i,1)>"9" or mid(str,i,1)<"0" then
				isInteger=false 
				Exit Function
			End If
		Next
		isInteger=true
		If err.number<>0 then err.clear
	End Function
	'================================================
	'作  用：补足参数
	'================================================
	Public Function Supplemental(para, n)
		Supplemental = ""
		If Not IsNumeric(para) Then Exit Function
		If Len(para) < n Then
			Supplemental = String(n - Len(para), "0") & para
		Else
			Supplemental = para
		End If
	End Function
	Public Function OutputScript(str,url)
		Response.Write "<script language=JavaScript>" & vbCrLf
		Response.Write "alert('" & str & "');"
		Response.Write "location.replace('" & url & "')" & vbCrLf
		Response.Write "</script>" & vbCrLf
		Response.End
	End Function
	Public Function OutHintScript(str)
		Response.Write "<script language=JavaScript>" & vbCrLf
		Response.Write "alert('" & str & "');"
		Response.Write "location.replace('" & Request.ServerVariables("HTTP_REFERER") & "')" & vbCrLf
		Response.Write "</script>" & vbCrLf
		Response.End
	End Function
	Public Function OutAlertScript(str)
		Response.Write "<script language=javascript>" & vbcrlf
		Response.Write "alert('" & str & "');"
		Response.Write "history.back()" & vbcrlf
		Response.Write "</script>" & vbcrlf
		Response.End
	End Function
End Class
%>
