<!--#include file="../../inc/count.asp"-->
<%
dim ComeUrl,cUrl,AdminName,Servername

ComeUrl=lcase(trim(request.ServerVariables("HTTP_REFERER")))
Servername=Request.ServerVariables("SERVER_NAME")
if ComeUrl="" and instr(lcase(request.ServerVariables("SCRIPT_NAME")),"admin_update.asp")=0 then
	response.write "<br><p align=center><font color='red'>对不起，为了系统安全，不允许直接输入地址访问本系统的后台管理页面。</font></p>"
	response.end
else
	cUrl=trim("http://" & servername)
	if mid(ComeUrl,len(cUrl)+1,1)=":" then
		cUrl=cUrl & ":" & Request.ServerVariables("SERVER_PORT")
	end if
	cUrl=lcase(cUrl & request.ServerVariables("SCRIPT_NAME"))
	'if lcase(left(ComeUrl,instrrev(ComeUrl,"/")))<>lcase(left(cUrl,instrrev(cUrl,"/"))) and instr(lcase(request.ServerVariables("SCRIPT_NAME")),"admin_update.asp")=0 then
		'response.write "<br><p align=center><font color='red'>对不起，为了系统安全，不允许从外部链接地址访问本系统的后台管理页面。</font></p>"
		'response.end
	'end if
end if
If instr(Lcase(request.ServerVariables("PATH_INFO")),Lcase(AdminDir))=0 then
        response.write "<br><p align=center><font color='red'>后台目录已经更改，请将后台目录更改为"&AdminDir&"再访问！</font></p>"
		response.end
End If
AdminName=replace(session("AdminName"),"'","")
if AdminName="" then
	call CloseConn()
	response.redirect "login.asp"
	response.End()
end if
sql="select UserName from Admin where UserName='" & session("AdminName") & "' and Password='" & session("AdminPassword") & "'"
set rs=conn.execute(sql)
if rs.eof and rs.bof then
  rs.close
  response.Redirect("login.asp")
  response.End()
end if
'**********************************************
'函数名：GetRecordCount(InfoId,TableName,Teams)
'**********************************************
Function GetRecordCount(InfoId,TableName,Teams)
	If Teams="0" then
		sql="select "&InfoId&" from ["&TableName&"] "
	Else
		sql="select "&InfoId&" from ["&TableName&"] "&Teams&""
	End If
	set RsGetRecordCount=server.createobject("adodb.recordset")
	RsGetRecordCount.open sql,Conn,1,1
	GetRecordCount=RsGetRecordCount.recordcount
	RsGetRecordCount.close:set RsGetRecordCount=nothing
End Function
Function GetAllCount(FieldName,TableName,Teams)
	If Teams="0" then
		sql="select "&FieldName&" from ["&TableName&"] "
	Else
		sql="select "&FieldName&" from ["&TableName&"] "&Teams&""
	End If
	set RsAll=server.createobject("adodb.recordset")
	RsAll.open sql,Conn,1,1
	do while not RsAll.eof
	   GetAllCount=GetAllCount+Clng(RsAll(0)) 
	RsAll.movenext
	loop
	RsAll.close:set RsAll=nothing
End Function

TotalInfo=GetRecordCount("Id","Product","0")+GetRecordCount("Id","News","0")
TotalUser=GetRecordCount("UserId","User","0")
TotalOrder=GetRecordCount("Id","OrderList","0")
TotalTrade=GetAllCount("BuyPrice","OrderDetail","0")
%>
