<!--#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
'Dim Purview,AllPurview,PurviewValue
AdminName=replace(session("AdminName"),"'","")
if AdminName="" then
	call CloseConn()
	Response.Write "<script language=javascript>this.top.location.href='Login.Asp';</script>"
	response.End()
end if
sql="select * 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.Write "<script language=javascript>this.top.location.href='Login.Asp';</script>"
  response.End()
Else
  Purview=Rs("Purview")
  AllPurview=Rs("AllPurview")  
end if
rs.close:set rs=nothing
'**********************************************
'函数名：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")
Sub ShowJS_Check()
    Response.Write "<SCRIPT language=javascript>" & vbCrLf
    Response.Write "function SelectAll(form){" & vbCrLf
    Response.Write "  for (var i=0;i<form.AdminPurview_Others.length;i++){" & vbCrLf
    Response.Write "    var e = form.AdminPurview_Others[i];" & vbCrLf
    Response.Write "    if (e.disabled==false)" & vbCrLf
    Response.Write "       e.checked = form.chkAll.checked;" & vbCrLf
    Response.Write "    }" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "function CheckAdd(){" & vbCrLf
    Response.Write "  if(document.form1.username.value==''){" & vbCrLf
    Response.Write "      alert('用户名不能为空！');" & vbCrLf
    Response.Write "   document.form1.username.focus();" & vbCrLf
    Response.Write "      return false;" & vbCrLf
    Response.Write "    }" & vbCrLf
    Response.Write "  if(document.form1.Password.value==''){" & vbCrLf
    Response.Write "      alert('密码不能为空！');" & vbCrLf
    Response.Write "   document.form1.Password.focus();" & vbCrLf
    Response.Write "      return false;" & vbCrLf
    Response.Write "    }" & vbCrLf
    Response.Write "  if((document.form1.Password.value)!=(document.form1.PwdConfirm.value)){" & vbCrLf
    Response.Write "      alert('初始密码与确认密码不同！');" & vbCrLf
    Response.Write "   document.form1.PwdConfirm.select();" & vbCrLf
    Response.Write "   document.form1.PwdConfirm.focus();" & vbCrLf
    Response.Write "      return false;" & vbCrLf
    Response.Write "    }" & vbCrLf
    Response.Write "  if (document.form1.Purview[1].checked==true){" & vbCrLf
    Response.Write " GetClassPurview();" & vbCrLf
    Response.Write "  }" & vbCrLf
    Response.Write "}" & vbCrLf
    
    Response.Write "function CheckModifyPwd(){" & vbCrLf
    Response.Write "  if(document.form1.Password.value==''){" & vbCrLf
    Response.Write "      alert('密码不能为空！');" & vbCrLf
    Response.Write "   document.form1.Password.focus();" & vbCrLf
    Response.Write "      return false;" & vbCrLf
    Response.Write "    }" & vbCrLf
    Response.Write "  if((document.form1.Password.value)!=(document.form1.PwdConfirm.value)){" & vbCrLf
    Response.Write "      alert('初始密码与确认密码不同！');" & vbCrLf
    Response.Write "   document.form1.PwdConfirm.select();" & vbCrLf
    Response.Write "   document.form1.PwdConfirm.focus();" & vbCrLf
    Response.Write "      return false;" & vbCrLf
    Response.Write "    }" & vbCrLf
    Response.Write "}" & vbCrLf
    
    Response.Write "function CheckModifyPurview(){" & vbCrLf
    Response.Write "  if (document.form1.Purview[1].checked==true){" & vbCrLf
    Response.Write " GetClassPurview();" & vbCrLf
    Response.Write "  }" & vbCrLf
    Response.Write "}" & vbCrLf

    Response.Write "function GetClassPurview(){" & vbCrLf
    
    Dim ChannelDir
    Dim sqlChannel, rsChannel
    sqlChannel = "select ChannelDir,ModuleType From MS_Channel where ChannelType<=1 and ModuleType <> 8 "
    sqlChannel = sqlChannel & "And Disabled=" & Value_False & " order by OrderID"
    Set rsChannel = Conn.Execute(sqlChannel)
    Do While Not rsChannel.EOF
        ChannelDir = rsChannel(0)
        If rsChannel(1) = 4 Then
            Response.Write "  document.form1.arrKind_Modify_" & ChannelDir & ".value='';" & vbCrLf
            Response.Write "  document.form1.arrKind_Del_" & ChannelDir & ".value='';" & vbCrLf
            Response.Write "  document.form1.arrKind_Move_" & ChannelDir & ".value='';" & vbCrLf
            Response.Write "  document.form1.arrKind_Check_" & ChannelDir & ".value='';" & vbCrLf
            Response.Write "  document.form1.arrKind_Quintessence_" & ChannelDir & ".value='';" & vbCrLf
            Response.Write "  document.form1.arrKind_SetOnTop_" & ChannelDir & ".value='';" & vbCrLf
            Response.Write "  document.form1.arrKind_Reply_" & ChannelDir & ".value='';" & vbCrLf
            Response.Write "  if(document.form1.AdminPurview_" & ChannelDir & "[2].checked==true){" & vbCrLf
            Response.Write "     for(var i=0;i<frm" & ChannelDir & ".document.myform.Purview_Modify.length;i++){" & vbCrLf
            Response.Write "         if (frm" & ChannelDir & ".document.myform.Purview_Modify[i].checked==true){" & vbCrLf
            Response.Write "             if (document.form1.arrKind_Modify_" & ChannelDir & ".value=='')" & vbCrLf
            Response.Write "                 document.form1.arrKind_Modify_" & ChannelDir & ".value=frm" & ChannelDir & ".document.myform.Purview_Modify[i].value;" & vbCrLf
            Response.Write "             else" & vbCrLf
            Response.Write "                 document.form1.arrKind_Modify_" & ChannelDir & ".value+=','+frm" & ChannelDir & ".document.myform.Purview_Modify[i].value;" & vbCrLf
            Response.Write "         }" & vbCrLf
            Response.Write "     }" & vbCrLf
            Response.Write "     for(var i=0;i<frm" & ChannelDir & ".document.myform.Purview_Del.length;i++){" & vbCrLf
            Response.Write "         if (frm" & ChannelDir & ".document.myform.Purview_Del[i].checked==true){" & vbCrLf
            Response.Write "             if (document.form1.arrKind_Del_" & ChannelDir & ".value=='')" & vbCrLf
            Response.Write "                 document.form1.arrKind_Del_" & ChannelDir & ".value=frm" & ChannelDir & ".document.myform.Purview_Del[i].value;" & vbCrLf
            Response.Write "             else" & vbCrLf
            Response.Write "                 document.form1.arrKind_Del_" & ChannelDir & ".value+=','+frm" & ChannelDir & ".document.myform.Purview_Del[i].value;" & vbCrLf
            Response.Write "         }" & vbCrLf
            Response.Write "     }" & vbCrLf
            Response.Write "     for(var i=0;i<frm" & ChannelDir & ".document.myform.Purview_Move.length;i++){" & vbCrLf
            Response.Write "         if (frm" & ChannelDir & ".document.myform.Purview_Move[i].checked==true){" & vbCrLf
            Response.Write "             if (document.form1.arrKind_Move_" & ChannelDir & ".value=='')" & vbCrLf
            Response.Write "                 document.form1.arrKind_Move_" & ChannelDir & ".value=frm" & ChannelDir & ".document.myform.Purview_Move[i].value;" & vbCrLf
            Response.Write "             else" & vbCrLf
            Response.Write "                 document.form1.arrKind_Move_" & ChannelDir & ".value+=','+frm" & ChannelDir & ".document.myform.Purview_Move[i].value;" & vbCrLf
            Response.Write "         }" & vbCrLf
            Response.Write "     }" & vbCrLf
            Response.Write "     for(var i=0;i<frm" & ChannelDir & ".document.myform.Purview_Check.length;i++){" & vbCrLf
            Response.Write "         if (frm" & ChannelDir & ".document.myform.Purview_Check[i].checked==true){" & vbCrLf
            Response.Write "             if (document.form1.arrKind_Check_" & ChannelDir & ".value=='')" & vbCrLf
            Response.Write "                 document.form1.arrKind_Check_" & ChannelDir & ".value=frm" & ChannelDir & ".document.myform.Purview_Check[i].value;" & vbCrLf
            Response.Write "             else" & vbCrLf
            Response.Write "                 document.form1.arrKind_Check_" & ChannelDir & ".value+=','+frm" & ChannelDir & ".document.myform.Purview_Check[i].value;" & vbCrLf
            Response.Write "         }" & vbCrLf
            Response.Write "     }" & vbCrLf
            Response.Write "     for(var i=0;i<frm" & ChannelDir & ".document.myform.Purview_Quintessence.length;i++){" & vbCrLf
            Response.Write "         if (frm" & ChannelDir & ".document.myform.Purview_Quintessence[i].checked==true){" & vbCrLf
            Response.Write "             if (document.form1.arrKind_Quintessence_" & ChannelDir & ".value=='')" & vbCrLf
            Response.Write "                 document.form1.arrKind_Quintessence_" & ChannelDir & ".value=frm" & ChannelDir & ".document.myform.Purview_Quintessence[i].value;" & vbCrLf
            Response.Write "             else" & vbCrLf
            Response.Write "                 document.form1.arrKind_Quintessence_" & ChannelDir & ".value+=','+frm" & ChannelDir & ".document.myform.Purview_Quintessence[i].value;" & vbCrLf
            Response.Write "         }" & vbCrLf
            Response.Write "     }" & vbCrLf
            Response.Write "     for(var i=0;i<frm" & ChannelDir & ".document.myform.Purview_SetOnTop.length;i++){" & vbCrLf
            Response.Write "         if (frm" & ChannelDir & ".document.myform.Purview_SetOnTop[i].checked==true){" & vbCrLf
            Response.Write "             if (document.form1.arrKind_SetOnTop_" & ChannelDir & ".value=='')" & vbCrLf
            Response.Write "                 document.form1.arrKind_SetOnTop_" & ChannelDir & ".value=frm" & ChannelDir & ".document.myform.Purview_SetOnTop[i].value;" & vbCrLf
            Response.Write "             else" & vbCrLf
            Response.Write "                 document.form1.arrKind_SetOnTop_" & ChannelDir & ".value+=','+frm" & ChannelDir & ".document.myform.Purview_SetOnTop[i].value;" & vbCrLf
            Response.Write "         }" & vbCrLf
            Response.Write "     }" & vbCrLf
            Response.Write "     for(var i=0;i<frm" & ChannelDir & ".document.myform.Purview_Reply.length;i++){" & vbCrLf
            Response.Write "         if (frm" & ChannelDir & ".document.myform.Purview_Reply[i].checked==true){" & vbCrLf
            Response.Write "             if (document.form1.arrKind_Reply_" & ChannelDir & ".value=='')" & vbCrLf
            Response.Write "                 document.form1.arrKind_Reply_" & ChannelDir & ".value=frm" & ChannelDir & ".document.myform.Purview_Reply[i].value;" & vbCrLf
            Response.Write "             else" & vbCrLf
            Response.Write "                 document.form1.arrKind_Reply_" & ChannelDir & ".value+=','+frm" & ChannelDir & ".document.myform.Purview_Reply[i].value;" & vbCrLf
            Response.Write "         }" & vbCrLf
            Response.Write "     }" & vbCrLf 
        Else
            Response.Write "  document.form1.arrClass_Input_" & ChannelDir & ".value='';" & vbCrLf
            Response.Write "  document.form1.arrClass_Check_" & ChannelDir & ".value='';" & vbCrLf
            Response.Write "  document.form1.arrClass_Manage_" & ChannelDir & ".value='';" & vbCrLf
            Response.Write "  if(document.form1.AdminPurview_" & ChannelDir & "[2].checked==true){" & vbCrLf
            Response.Write "     for(var i=0;i<frm" & ChannelDir & ".document.myform.Purview_View.length;i++){" & vbCrLf
            Response.Write "         if (frm" & ChannelDir & ".document.myform.Purview_View[i].checked==true){" & vbCrLf
            Response.Write "             if (document.form1.arrClass_View_" & ChannelDir & ".value=='')" & vbCrLf
            Response.Write "                 document.form1.arrClass_View_" & ChannelDir & ".value=frm" & ChannelDir & ".document.myform.Purview_View[i].value;" & vbCrLf
            Response.Write "             else" & vbCrLf
            Response.Write "                 document.form1.arrClass_View_" & ChannelDir & ".value+=','+frm" & ChannelDir & ".document.myform.Purview_View[i].value;" & vbCrLf
            Response.Write "         }" & vbCrLf
            Response.Write "     }" & vbCrLf
            Response.Write "     for(var i=0;i<frm" & ChannelDir & ".document.myform.Purview_Input.length;i++){" & vbCrLf
            Response.Write "         if (frm" & ChannelDir & ".document.myform.Purview_Input[i].checked==true){" & vbCrLf
            Response.Write "             if (document.form1.arrClass_Input_" & ChannelDir & ".value=='')" & vbCrLf
            Response.Write "                 document.form1.arrClass_Input_" & ChannelDir & ".value=frm" & ChannelDir & ".document.myform.Purview_Input[i].value;" & vbCrLf
            Response.Write "             else" & vbCrLf
            Response.Write "                 document.form1.arrClass_Input_" & ChannelDir & ".value+=','+frm" & ChannelDir & ".document.myform.Purview_Input[i].value;" & vbCrLf
            Response.Write "         }" & vbCrLf
            Response.Write "     }" & vbCrLf
            Response.Write "     for(var i=0;i<frm" & ChannelDir & ".document.myform.Purview_Check.length;i++){" & vbCrLf
            Response.Write "         if (frm" & ChannelDir & ".document.myform.Purview_Check[i].checked==true){" & vbCrLf
            Response.Write "             if (document.form1.arrClass_Check_" & ChannelDir & ".value=='')" & vbCrLf
            Response.Write "                 document.form1.arrClass_Check_" & ChannelDir & ".value=frm" & ChannelDir & ".document.myform.Purview_Check[i].value;" & vbCrLf
            Response.Write "             else" & vbCrLf
            Response.Write "                 document.form1.arrClass_Check_" & ChannelDir & ".value+=','+frm" & ChannelDir & ".document.myform.Purview_Check[i].value;" & vbCrLf
            Response.Write "         }" & vbCrLf
            Response.Write "     }" & vbCrLf
            Response.Write "     for(var i=0;i<frm" & ChannelDir & ".document.myform.Purview_Manage.length;i++){" & vbCrLf
            Response.Write "         if (frm" & ChannelDir & ".document.myform.Purview_Manage[i].checked==true){" & vbCrLf
            Response.Write "             if (document.form1.arrClass_Manage_" & ChannelDir & ".value=='')" & vbCrLf
            Response.Write "                 document.form1.arrClass_Manage_" & ChannelDir & ".value=frm" & ChannelDir & ".document.myform.Purview_Manage[i].value;" & vbCrLf
            Response.Write "             else" & vbCrLf
            Response.Write "                 document.form1.arrClass_Manage_" & ChannelDir & ".value+=','+frm" & ChannelDir & ".document.myform.Purview_Manage[i].value;" & vbCrLf
            Response.Write "         }" & vbCrLf
            Response.Write "     }" & vbCrLf
        End If
        Response.Write " }" & vbCrLf
        rsChannel.MoveNext
    Loop
    rsChannel.Close
    Set rsChannel = Nothing
    Response.Write "}" & vbCrLf
    Response.Write "</SCRIPT>" & vbCrLf
End Sub

Function CheckAdmin(PurviewValue)
    CheckAdmin=False
    If Purview=1 then
		CheckAdmin=True
	ElseIf Purview=2 then
		If FoundInArr(AllPurview,PurviewValue,",") then CheckAdmin=True
	Else
		CheckAdmin=False
	End If
End Function
%>
