<!--#include file="../Include/Class_Conn.asp" -->
<!--#include file="../Include/Class_Pass.asp" -->
<!--#include file="../Include/Class_Main.asp" -->

<%
Dim SQL,Rs
Dim Username,Password,Code,Re,LoginIp,Thesoft
Username=SafeRequestform("username")
Password=SafeRequestform("password")
Password=md5(password)
City = SafeRequestform("city")
Code=SafeRequestform("code")

'//检测是否是跨站登陆
'If Instr(Lcase(request.serverVariables("HTTP_REFERER")),Lcase(request.ServerVariables("Server_Name")))=0 Then
 'Response.Write Cls_WebName&"提示：非法操作！"
 'Response.End()
'End If 

If username="" or Password="" Then 
 Response.Write"<script>alert(""用户名和密码不能为空！ "");history.back(-1)"";</script>"
 Response.end
End If

If  Code <> CStr(Session("GetCode"))  Then 
 Response.Write"<script>alert(""验证码不正确，请刷新后重新登陆! "");location.href=""Web_Login.asp"";</script>"
 Response.end
End If

Set Rs = Server.createobject("ADODB.recordset")
Set Re = Server.createobject("ADODB.recordset")

SQL = "Select SupperName From [pH_Web_City] Where SupperName='"&UserName&"' And Cityid="&City
Rs.open SQL,Conn,1,1
If Rs.eof  Then
 '//管理员用户名不正确
 Rs.close
 Set Rs=Nothing
 Set Re=Nothing
 CloseDB
 Response.Write "<script>alert('管理用户帐号或者密码不正确，请重新登陆...');location.href='Web_Login.asp';</script>"
 response.End()
Else
 Re.open "select Cityid,SupperName,Password,Flag,c_Name from [pH_Web_City] where SupperName='"&UserName&"' And Password='"&Password&"' And Cityid="&City,conn,1,1
 If re.eof Then
  '//管理员密码不正确
  rs.close
  re.close
  set rs=nothing
  set re=nothing
  CloseDB
  Response.Write "<script>alert('管理用户帐号或者密码不正确，请重新登陆...');location.href='Web_Login.asp';</script>"
  response.End()
 Else
   '//再次检测密码是否正确
   If Password=Trim(re("password")) Then
    '//检测管理员帐号是否有效
    If Re("Flag") = True Then
	  '//生成登陆标记
	  Dim key
      Randomize
	  key=cstr(Int((999999-1+100000)*Rnd+1))
	  '//登陆成功
	  Response.Cookies ("Web_cookies") = key
	  Session("Web_Suppername")        = Re("suppername")
	  Session("Web_PassWord")          = Re("PassWord")
      Session("c_City")				   = Re("Cityid")
	  Session("c_Name")				   = Re("c_Name")
	  Response.Redirect "Web_Index.asp"
     Else
      Response.Write "<script>alert('您登陆的分站被屏蔽！不能登陆...');location.href='Web_Login.asp';</script>"
      Response.End()
     End if 
    Else 
	  Response.Write "<script>alert('管理用户帐号或者密码不正确，请重新登陆...');location.href='Web_Login.asp';</script>"
      Response.End()
    End If

 End If
End If
'//关闭数据库连接
Rs.close
Re.close
Set rs=nothing
Set re=nothing
Call CloseDB()	

%>
