<!--#include file="setup.asp"-->
<!--#include file="iNCchuanqi/Md5.asp"-->
<%
'╭──CaiSF发布网───────────────╮
'┃　　　　　　      　　             　　 ┃
'┃程序类型:发布站程序　　　　　　　       ┃
'┃购买认证:冰精灵GM基地　　　　　         ┃
'┃程序版本:Ver6.0　　　　　　　           ┃
'┃程序作者:CaiSF发布网　　　　　　　           ┃
'┃联 系 QQ:53660542 282538600            ┃
'┃联系电话:18279334567　　　　　　　      ┃
'┃官方网站:http://Www.CaiSF.COM            ┃
'┃版权所有:CaiSF发布网　　　　　　             ┃
'┃　　　　　　　　             　　　　   ┃
'┃　         版权声明：转载请保留版权信息 ┃
'╰───────────Cool network───╯
Response.CacheControl = "no-cache"
Dim loginok, RefreshTime, GetCode
FoundErr = False
loginok = 0         '是否开启登陆提示，1=开启，0=关闭
RefreshTime = 3     '设置防刷新时间
If DateDiff("s", Session("UserTime"), Now()) < RefreshTime Then
    Response.Write "<META http-equiv=Content-Type content=text/html; chaRset=gb2312><meta HTTP-EQUIV=REFRESH CONTENT="&RefreshTime&"><br>本页面起用了防刷新机制，请不要在"&RefreshTime&"秒内连续刷新本页面<BR>正在打开页面，请稍后……"
    Response.End
End If
FoundErr = False
Select Case QiKuCMS.CheckStr(Request("action"))
  Case "logout" '退出系统
    Call logout()
  Case "login" '登陆系统
    Call chklogin()
  Case Else
    Call main()
End Select
If Founderr = True Then
    Session("UserTime") = Now()
    Response.Redirect("showerr.asp?action=error&message=" & Server.URLEncode(ErrMsg) & "")
End If
CloseConn
Sub main()
    If Session("LoginName") = "" Then
    Response.Write "<html>"
    Response.Write "<head>"
    Response.Write "<meta http-equiv=""Content-Type"" content=""text/html; charset=gb2312"">"
    Response.Write "<title>管理员登录 - " & QiKuCMS.WebName & " - Powered By Cool network Ver6.0</title>"
    Response.Write "<LINK href=""Images/QiKuCMS.css"" type=text/css rel=stylesheet>"
    Response.Write "</head>"
    Response.Write "<script language=""javascript"">" & vbCrLf
    Response.Write "<!--//" & vbCrLf
    Response.Write "function SetFocus()" & vbCrLf
    Response.Write "{" & vbCrLf
    Response.Write "if (document.myform.LoginName.value=="""")" & vbCrLf
    Response.Write "document.myform.LoginName.focus();" & vbCrLf
    Response.Write "else" & vbCrLf
    Response.Write "document.myform.LoginName.select();" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "function CheckForm()" & vbCrLf
    Response.Write "{" & vbCrLf
    Response.Write "if(document.myform.LoginName.value=="""")" & vbCrLf
    Response.Write "{" & vbCrLf
    Response.Write "alert(""请输入您的用户名！"");" & vbCrLf
    Response.Write "document.myform.LoginName.focus();" & vbCrLf
    Response.Write "return false;" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "if(document.myform.password.value == """")" & vbCrLf
    Response.Write "{" & vbCrLf
    Response.Write "alert(""请输入您的密码！"");" & vbCrLf
    Response.Write "document.myform.password.focus();" & vbCrLf
    Response.Write "return false;" & vbCrLf
    Response.Write "}" & vbCrLf
    If IsAdminValidate Then
    Response.Write "if(document.myform.validate.value == """")" & vbCrLf
    Response.Write "{" & vbCrLf
    Response.Write "alert(""请输入您的认证码！"");" & vbCrLf
    Response.Write "document.myform.validate.focus();" & vbCrLf
    Response.Write "return false;" & vbCrLf
    Response.Write "}" & vbCrLf
    End If
    Response.Write "if (document.myform.verifycode.value==""""){" & vbCrLf
    Response.Write "alert (""请输入您的验证码！"");" & vbCrLf
    Response.Write "document.myform.verifycode.focus();" & vbCrLf
    Response.Write "return(false);" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "function CheckBrowser()" & vbCrLf
    Response.Write "{" & vbCrLf
    Response.Write "var app=navigator.appName;" & vbCrLf
    Response.Write "var verStr=navigator.appVersion;" & vbCrLf
    Response.Write "if (app.indexOf('Netscape') != -1) {" & vbCrLf
    Response.Write "alert(""CaiSF发布网情提示：\n    你使用的是Netscape浏览器，可能会导致无法使用后台的部分功能。建议您使用 IE6.0 或以上版本。"");" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "else if (app.indexOf('Microsoft') != -1) {" & vbCrLf
    Response.Write "if (verStr.indexOf(""MSIE 3.0"")!=-1 || verStr.indexOf(""MSIE 4.0"") != -1 || verStr.indexOf(""MSIE 5.0"") != -1 || verStr.indexOf(""MSIE 5.1"") != -1)" & vbCrLf
    Response.Write "alert(""CaiSF发布网情提示：\n    您的浏览器版本太低，可能会导致无法使用后台的部分功能。建议您使用 IE6.0 或以上版本。"");" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "}" & vbCrLf
    Response.Write "//-->" & vbCrLf
    Response.Write "</script>"
    Response.Write "<body topmargin=""0"" leftmargin=""0"" rightmargin=""0"">"
    Response.Write "<p>&nbsp;</p>"
    Response.Write "<table  border=""0"" align=center cellpadding=""0"" cellspacing=""0"" background='images/login.jpg'>"
    Response.Write "<form name=myform method=""post"" action=""?action=login"" target=""_top"" onSubmit=""return CheckForm();"">"
    Response.Write "<tr>"
    Response.Write "<td height=462><table width=""873"" border=""0"" align=""center"" cellpadding=""0"" cellspacing=""0"" >"
    Response.Write "<tr>"
	response.Write "<td width=5>"
	Response.Write "<td align=center></td>"
    Response.Write "<td width=""473"" align=""center""  height=445>"
    Response.Write "<table width=""90%""  border=""0"" align=""center"" cellpadding=""10"" cellspacing=""0"">"
    response.write "<tr><td><img src=images/logo.gif></tr>"
    response.write "<tr><td style='font-size:12px; color:#666666;font-weight:bold;'></tr>"	
    Response.Write "<tr>"
    Response.Write "<td width=""78%"" align=""left""><FONT color=#666666>登录帐号： <input name=""LoginName"" type=""text"" size=""25"" maxlength=""20"" class=""zhuce_lt_in""></td>"
    Response.Write "</tr>"
    Response.Write "<tr>"
    Response.Write "<td align=""left""><FONT color=#666666>登录密码： <input name=""password"" type=""password"" size=""25"" maxlength=""15"" class=""zhuce_lt_in""></td>"
    Response.Write "</tr>"
    If IsAdminValidate Then
    Response.Write "<tr>"
    Response.Write "<td align=""left""><FONT color=#666666>安全验证： <input name=""validate"" type=""password"" size=""25"" class=""zhuce_lt_in""></td>"
    Response.Write "</tr>"
    End If
    Response.Write "<tr>"
    Response.Write "<td align=""left""><FONT color=#666666>安全验证： <input name=""verifycode"" type=""text"" size=""8"" maxlength=""4"" value="""
    If GetCode=9999 Then Response.Write "9999"
    Response.Write """ class=""zhuce_lt_i""> "
    Response.Write "验证码<img src=""iNCchuanqi/Gqcode.asp"" alt=""看不清楚?请点击刷新验证码"" height=""10"" style=""cursor : pointer;"" onclick=""this.src='iNC/Gqcode.asp'"" /></td>"
    Response.Write "</tr>"
    Response.Write "<tr>"
    Response.Write "<td align=""left"">"
    Response.Write "<input type='hidden' name='Action' value='Login'>"
    Response.Write "<input type=""submit"" name=""Submit"" value=""登陆后台"" class=BtnD>"
    Response.Write "<input onclick=window.location.reload() type=button value=""刷新本页"" name=refresh class=BtnD>"
    Response.Write "</td>"
    Response.Write "</tr>"
    Response.Write "</table></td>"
    Response.Write "</tr>"
    Response.Write "</form>"
    Response.Write "</table>"
    Response.Write "</body>"
    Response.Write "</html>"
    Else
    Response.Redirect "admin_index.asp"
    End If
End Sub
Sub logout()
    '清除COOKIES中管理员身份的验证信息.
    'Session.Abandon
    Session("LoginName") = ""
    Session("AdminPass") = ""
    Session("AdminGrade") = ""
    Session("AdminFlag") = ""
    Session("AdminStatus") = ""
    Session("AdminID") = ""
    Session("validate") = ""
    Session("AdminRandomCode") = ""
    Response.Cookies(Admin_Cookies_Name) = ""
    Response.Redirect ("../")
End Sub
Sub chklogin()
    Dim LoginName, password, RandomCode
    LoginName = QiKuCMS.CheckBadstr(Request("LoginName"))
    password = md5(Trim(Replace(Request("password"), "'", "")))
    RandomCode = QiKuCMS.CheckBadstr(Request("RandomCode"))
    If QiKuCMS.CheckPost = False Then
        ErrMsg = ErrMsg + "您提交的数据不合法，请不要从外部提交登陆！！！"
        Founderr = True
    End If
    If IsValidStr(Request("LoginName")) = False Then
        ErrMsg = ErrMsg + "<li>用户名中含有非法字符！</li>"
        Founderr = True
    End If
    If IsValidPassword(Request("password")) = False Then
        ErrMsg = ErrMsg + "<li>密码中含有非法字符！</li>"
        Founderr = True
    End If
    If IsAdminValidate Then
        If Trim(Request.Form("validate")) <> AdminValidateCode Or Trim(Request.Form("validate")) = "" Then
            ErrMsg = ErrMsg+"<li>您输入的认证码不正确，请重新输入！</li>"
            Founderr = true
        Exit Sub
        End if
    End If
    If Request("verifycode") = "" Then
        ErrMsg = ErrMsg + "<br>" + "<li>请返回输入确认码！</li>"
        Founderr = True
    ElseIf Session("getcode") = "9999" Then
        Session("getcode") = ""
        ErrMsg = ErrMsg + "<br>" + "<li>请不要重复提交，如需重新登陆请返回登陆页面！</li>"
        Founderr = True
    ElseIf CStr(Session("getcode"))<>CStr(Trim(Request("verifycode"))) Then
        ErrMsg = ErrMsg + "<br>" + "<li>您输入的验证码与系统产生的不一致，请重新输入！</li>"
        Founderr = True
    End If
        Session("getcode") = ""
    If LoginName = "" Or password = "" Then
        Founderr = True
        ErrMsg = ErrMsg + "<br>" + "<li>请输入您的用户名或密码。</li>"
        Exit Sub
    End If
    If Founderr = True Then Exit Sub
        If Not IsObject(Conn) Then ConnectionDatabase
        Set Rs = Server.CreateObject("ADODB.Recordset")
        SQL = "SELECT * FROM Gq_Admin WHERE AdminName='" & LoginName & "'"
        Rs.Open SQL, Conn, 1, 3
        If Rs.BOF And Rs.EOF Then
            FoundErr = True
            ErrMsg = ErrMsg + "<li>您输入的用户名不正确！</li>"
            Exit Sub
        Else
        If password <> Rs("password") Then
            FoundErr = True
            ErrMsg = ErrMsg + "<br><li>您输入的密码不正确！</li>"
            Exit Sub
        End If
        If Rs("isLock") <> 0 Or Rs("isLock") = "" Then
            Founderr = True
            ErrMsg = "<li><font color=red>抱歉，您的帐号已被锁定！如要开通，请联系高级管理员！</font></li>"
            Exit Sub
        End If
        End If
        RandomCode = QiKuCMS.GetRandomCode
        Rs("LoginTime") = Now()
        Rs("Loginip") = QiKuCMS.GetUserip
        Rs("RandomCode") = RandomCode
        Rs.Update
        If FoundErr = False Then
            Session("LoginName") = Rs("AdminName")
            Session("AdminPass") = Rs("password")
            Session("AdminGrade") = Rs("AdminGrade")
            Session("AdminFlag") = Rs("Authority")
            Session("AdminStatus") = Rs("Status")
            Session("AdminRandomCode") = RandomCode
            Session("AdminID") = Rs("id")
        If IsAdminValidate Then
            Session("validate") = Trim(Request.Form("validate"))
        End If
        If UseAdminCookies Then
            Response.Cookies(Admin_Cookies_Name)("LoginName") = Rs("AdminName")
            Response.Cookies(Admin_Cookies_Name)("AdminPass") = Rs("password")
            Response.Cookies(Admin_Cookies_Name)("AdminGrade") = Rs("AdminGrade")
            Response.Cookies(Admin_Cookies_Name)("AdminFlag") = Rs("Authority")
            Response.Cookies(Admin_Cookies_Name)("AdminStatus") = Rs("Status")
            Response.Cookies(Admin_Cookies_Name)("RandomCode") = RandomCode
            Response.Cookies(Admin_Cookies_Name)("AdminID") = Rs("ID")
        If IsAdminValidate Then
            Response.Cookies(Admin_Cookies_Name)("validate") = Trim(Request.Form("validate"))
        End If
        End If
    End If
    Rs.Close
    Set Rs = Nothing
    Response.Redirect ("admin_Index.asp")
End Sub
%>

