<!--#include file="conn.asp"-->

<% 
 '===========================================================================================
	'软件名称：126 cms 视频影视管理系统
	'程序版权：126电影               '咨询QQ：479025
	'开发作者：magicblack(479025)    '官方网站：http://www.126oo.com/
	'Copyright (C) 2009 - ... 126oo.com  All Rights Reserved.
	'郑重声明:
	'    1、免费版本请在程序首页保留版权信息，并做上本站LOGO友情连接,商业版本无此要求;
	'    2、任何个人或组织不得以盈利为目的发布,修改,本软件及其他副本上一切关于版权的信息；
	'    3、126电影保留此软件的法律追究权利；
'==========================================================================================
%>

<%
response.Charset="GBK"
dim action
action = SafeData("RQ","action",0)

Select case action
	case "login" : login
	case "check" : checkLogin
	case "logout" : logout
	case else : main
End Select

Sub checkLogin
dim adminname,password,msg,founderr,rs,randnum,verifycode

adminname = SafeData("RF","adminname",0)
password = md5(SafeData("RF","password",0))
verifycode = SafeData("RF","verifycode",0)

	if verifycode ="" then
		msg=msg+"<br>"+"<li>请返回输入确认码。<li><b>返回后请刷新登陆页面后重新输入正确的信息。</b>"
		founderr=true
	elseif request.cookies("verifycode")="" then
		msg=msg+"<br>"+"<li>请不要重复提交，如需重新登陆请返回登陆页面。<li><b>返回后请刷新登陆页面后重新输入正确的信息。</b>"
		founderr=true
	elseif request.cookies("verifycode")<> trim(request("verifycode")) then
		msg=msg+"<br>"+"<li>您输入的确认码和系统产生的不一致，请重新输入。<li><b>返回后请刷新登陆页面后重新输入正确的信息。</b>"
		founderr=true
	end if
	response.cookies("verifycode")=""
	if adminname="" or password="" then
		founderr=true
		msg=msg+"<br>"+"<li>请输入您的用户名或密码。<li><b>返回后请刷新登陆页面后重新输入正确的信息。</b>"
	end if
 if founderr then ErrMsg "登陆错误",msg

	set rs= Database.GetRecordDetail("Tbl_Manager","M_Name='"&adminname&"' and M_PassWrod = '"&password&"' and M_Status =1")
	if rs.eof and rs.bof then
		rs.close
		set rs=nothing
		 AlertUrl "您输入的用户名和密码不正确或者您不是系统管理员!","?action=login"
		exit sub
	else
		response.cookies("AdminName")=rs("M_Name")
		response.cookies("adminid")=rs("M_ID")
		randomize
		randnum = rnd*9999
		response.cookies("rand")  = randnum
		response.cookies("check")= md5(randnum&rs("M_Name")&rs("M_ID"))
		Database.UpdateRecord "Tbl_Manager", "M_Name ='"&adminname&"'", Array("M_LoginTime:"&Now(), "M_LoginIp:"&GetIP())
		Database.C(rs)
		writeflush "<script>top.location.href='index.asp';</script>"
	end if
End Sub

sub logout
response.cookies("AdminName")=""
response.cookies("adminid")=""
response.cookies("rand") = ""
writeflush "<script>top.location.href='index.asp?action=login';</script>"
end sub

sub login
		Dim num1
		Dim rndnum
		Randomize
		Do While Len(rndnum)<4
		num1=CStr(Chr((57-48)*rnd+48))
		rndnum=rndnum&num1
		Loop
		response.cookies("verifycode") = rndnum
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link href="images/css_login.css" rel="stylesheet" type="text/css" />
<title>后台管理中心 - 126电影程序CMS</title></head>
<body>
<div class="main">
    <div class="title">
			&nbsp;
	  </div>
		<div class="login">
		<form action="?action=check" method="post">
            <div class="inputbox">
				<dl>
				  <dd>用户名：</dd>
					<dd><input type="text" name="AdminName" id="AdminName" size="25" onfocus="this.style.borderColor='#fc9938'" onblur="this.style.borderColor='#dcdcdc'" />
					</dd>
					<dd>密码：</dd>
					<dd><input type="password" name="password" size="25" onfocus="this.style.borderColor='#fc9938'" onblur="this.style.borderColor='#dcdcdc'" />
					</dd>
					<dd>验证码: &nbsp;<input name="verifycode" maxlength="20" size="12" class="tableBorder" value="<%=request.cookies("verifycode")%>">
                  </dd>  
              </dl>
          </div>
		  <div style="text-align:center">
				<dl>
				  <dd>&nbsp;<input name="submit" type="submit" value="登陆" class="input" />
                  </dd>
              </dl>
          </div>
		  
            <div class="butbox">
            <dl>
					<dt></dt>
					<dd>
                    采用asp和mssql access等多种数据库构建的高效影视站解决方案</a></dd>
			  </dl>
			</div>
            <div style="clear:both"></div>
		</form>
		</div>
	</div>
	</body>
	</html>
<%
end sub

sub main
chklogin
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>后台管理中心 - 126电影程序CMS</title>
<META content="MSHTML 6.00.3790.4275" name=GENERATOR>
</HEAD>
<FRAMESET border=0 frameSpacing=0 rows=76,* frameBorder=0 cols=*>
<FRAME id=topFrame name=topFrame src="Admin_Top.asp" noResize scrolling=no>
<FRAMESET id=bodyFrame border=0 frameSpacing=0 frameBorder=NO cols=176,* noresize scrolling="yes">
<FRAME id=left name=left src="admin_left_system.asp" frameBorder=0 scrolling=yes>
<FRAME id=right name=right marginWidth=0 marginHeight=0 src="Admin_Right.asp" frameBorder=0 scrolling=yes>
</FRAMESET></FRAMESET>
<noframes></noframes>
</HTML>
<%
end sub


	dim manageurl
	manageurl=Request.ServerVariables("url")
	manageurl=LCase(manageurl)
	If InStr(manageurl,"/admin/")>0 Then 
		response.write"<script>alert('请将默认管理目录admin改名,避免被攻击！');</script>"
	End If 
%>
