威凡网全力打造:网页编程、软件开发编程、平面设计、服务器端开发、操作系统等在线学习平台!学编程,上威凡网!
ASP教程>> ASP基础 应用技巧 数据库相关 ASP类 存储过程 FSO专栏 ASP其他
当前位置:首页 > ASP教程 > 存储过程
上一节 下一节
 登陆asp class
代码如下:

<!-- #include file="conn.asp" -->
<!-- #include file="cls_main.asp" -->
<!-- #include file="cls_md5.asp" -->
<% dim obj
set obj = new admin_login
    call obj.main()
set obj = nothing

class admin_login
    private founderr, errmsg,mesky
    private sub class_initialize()
        founderr = false
        set mesky = new cls_main
    end sub
    private sub class_terminate()
        set mesky = nothing
    end sub
    public sub main()
        response.write "<!doctype html public ""-//w3c//dtd html 4.01 transitional//en"" ""http://www.w3.org/tr/html4/loose.dtd"">" & vbcrlf
        response.write "<html>" & vbcrlf
        response.write "<head>" & vbcrlf
        response.write "<meta http-equiv=""content-type"" content=""text/html; charset=gb2312"">" & vbcrlf
        response.write "<title>动感下载系统 v3.0 ——管理员登录        powered by:www.mesky.net      </title>" & vbcrlf
        response.write "</head>" & vbcrlf
        response.write "<style type=text/css>" & vbcrlf
        response.write "body {" & vbcrlf
        response.write "    background:#efefef;" & vbcrlf
        response.write "    font-size: 12px;" & vbcrlf
        response.write "    margin-top:0px;" & vbcrlf
        response.write "}" & vbcrlf
        response.write vbcrlf
        response.write "input {" & vbcrlf
        response.write vbcrlf
        response.write "    font-size: 12px;" & vbcrlf
        response.write "    font-family: ""宋体"";" & vbcrlf
        response.write "}" & vbcrlf
        response.write "span {" & vbcrlf
        response.write "    font-size: 12px; position: static" & vbcrlf
        response.write "}" & vbcrlf
        response.write "a:link,a:visited  {" & vbcrlf
        response.write "    color: #0033ff;" & vbcrlf
        response.write "    text-decoration: none;" & vbcrlf
        response.write "}" & vbcrlf
        response.write "</style>" & vbcrlf
        response.write "<p> </p>" & vbcrlf
        response.write "<p> </p>" & vbcrlf
        response.write "<table align=center width=380 style=""border: outset 3px;"" cellpadding=0 cellspacing=0 id=""table1"">" & vbcrlf
        response.write "    <tr>" & vbcrlf
        response.write "        <td style=""padding:3px;background-color:blue;color:white;"">login meskydms v3    powered by:www.mesky.cn</td>" & vbcrlf
        response.write "    </tr>" & vbcrlf
        response.write "    <tr valign=top>" & vbcrlf
        response.write "        <td><img src=""images/admin_title.gif"" width=""100%""></td>" & vbcrlf
        response.write "    </tr>" & vbcrlf
        response.write "    <tr>" & vbcrlf
        response.write "        <td style=""padding:15px;"">" & vbcrlf
        dim username
        dim password
        dim ip
        dim browsertype

        
        select case request("action")
            case "chklogin"
                call chklogin
                if founderr then
                    response.write (errmsg)
                    response.write ("<br><br><< = <a href=""admin_login.asp"">返回管理员登录页</a>")
                end if
            case "logout"
                call logout
            case else
                call login
        end select
        response.write "        </td>" & vbcrlf
        response.write "    </tr>" & vbcrlf
        response.write "    <tr><td style=""padding:10px;"">" & vbcrlf
        set browsertype = new cls_browser
            response.write ("客户端操作系统:" & browsertype.platform & "<br>客户端浏览器: " & browsertype.browser & browsertype.version) & vbcrlf
        set browsertype = nothing
        response.write "</td></tr>" & vbcrlf
        response.write "</table><br><br>" & vbcrlf
        response.write "</body>" & vbcrlf
        response.write "</html>" & vbcrlf
    end sub
    sub logout()    '用户退出
        session("adminname") = ""
        session("adminpass") = ""
        call login
    end sub

    sub login() '用户登录
    on error resume next
    dim ados, getcode
    ' ados = server.createobject("adodb.stream")
    if err then
        getcode = 9999
    end if
        response.write "<script language=""javascript""><!--" & vbcrlf
        response.write "function vf_loginform(){ //v2.0" & vbcrlf
        response.write "<!--start_of_saved_settings-->" & vbcrlf
        response.write "<!--type,text,name,verifycode,required,true,isnum,errmsg,请填写右边的确认密码。-->" & vbcrlf
        response.write "<!--type,password,name,password,required,true,errmsg,请填写登录密码!-->" & vbcrlf
        response.write "<!--type,text,name,username,required,true,errmsg,请填写登录用户名!-->" & vbcrlf
        response.write "<!--end_of_saved_settings-->" & vbcrlf
        response.write "    var theform = document.loginform;" & vbcrlf
        response.write "    var numre = /^d+$/;" & vbcrlf
        response.write "    var errmsg = """";" & vbcrlf
        response.write "    var setfocus = """";" & vbcrlf
        response.write vbcrlf
        response.write "    if (!numre.test(theform['verifycode'].value)){" & vbcrlf
        response.write "        errmsg = ""请填写右边的确认密码。"";" & vbcrlf
        response.write "        setfocus = ""['verifycode']"";" & vbcrlf
        response.write "    }" & vbcrlf
        response.write "    if (theform['password'].value == """"){" & vbcrlf
        response.write "        errmsg = ""请填写登录密码!"";" & vbcrlf
        response.write "        setfocus = ""['password']"";" & vbcrlf
        response.write "    }" & vbcrlf
        response.write "    if (theform['username'].value == """"){" & vbcrlf
        response.write "        errmsg = ""请填写登录用户名!"";" & vbcrlf
        response.write "        setfocus = ""['username']"";" & vbcrlf
        response.write "    }" & vbcrlf
        response.write "    if (errmsg != """"){" & vbcrlf
        response.write "        alert(errmsg);" & vbcrlf
        response.write "        eval(""theform"" + setfocus + "".focus()"");" & vbcrlf
        response.write "    }" & vbcrlf
        response.write "    else theform.submit();" & vbcrlf
        response.write "}//-->" & vbcrlf
        response.write "</script>" & vbcrlf
        response.write "        <table  border=""0"">" & vbcrlf
        response.write "        <form action=""?action=chklogin"" method=""post"" name=""loginform"" onsubmit=""vf_loginform();return false;""> " & vbcrlf
        response.write "          <tr>" & vbcrlf
        response.write "            <td><span style=""width:80px;"">用户名:</span></td>" & vbcrlf
        response.write "            <td><input maxlength=20 type=""text"" name=""username"" style=""width:200px;"" tabindex=""1""></td>" & vbcrlf
        response.write "          </tr>" & vbcrlf
        response.write "          <tr>" & vbcrlf
        response.write "            <td><span style=""width:80px;"">密 码:</span></td>" & vbcrlf
        response.write "            <td><input maxlength=20 type=""password"" name=""password"" style=""width:200px;""></td>" & vbcrlf
        response.write "          </tr>" & vbcrlf
        response.write "          <tr>" & vbcrlf
        response.write "            <td><span style=""width:80px;"">验证码:</span></td>" & vbcrlf
        response.write "            <td><input name=""verifycode"" type=""text"" style=""width:60px;"" value="""
        if getcode = 9999 then response.write "9999"
        response.write """  maxlength=4> " & vbcrlf
        response.write "            请在验证码框输入:<img src=""getcode.asp""></td>" & vbcrlf
        response.write "          </tr>" & vbcrlf
        response.write "          <tr>" & vbcrlf
        response.write "            <td> </td>" & vbcrlf
        response.write "            <td align=""right""> </td>" & vbcrlf
        response.write "          </tr>" & vbcrlf
        response.write "          <tr>" & vbcrlf
        response.write "            <td> </td>" & vbcrlf
        response.write "            <td align=""right""><input type=""submit"" value=""登 录..."" name=""btnsubmit"" style=""width:80px;font:menu;"" id=""submit1""></td>" & vbcrlf
        response.write "          </tr>" & vbcrlf
        response.write "          </form>  " & vbcrlf
        response.write "        </table>" & vbcrlf

    end sub
    '检验用户登录
    sub chklogin()
        dim username,password,ip
        username = trim(replace(request("username"), "'", ""))
        password = md5(trim(replace(request("password"), "'", "")), 16)
        if request("verifycode") = "" then
            errmsg = errmsg + "<br>" + "<li>请返回输入确认码。"
            founderr = true
        elseif session("getcode") = "9999" then
            session("getcode") = ""
        elseif session("getcode") = "" then
            errmsg = errmsg + "<br>" + "<li>请不要重复提交,如需重新登陆请返回登陆页面。"
            founderr = true
        elseif cstr(session("getcode")) <> cstr(trim(request("verifycode"))) then
            errmsg = errmsg + "<br>" + "<li>您输入的确认码和系统产生的不一致,请重新输入。"
            founderr = true
        end if
        session("getcode") = ""
        if username = "" or password = "" then
            founderr = true
            errmsg = errmsg + "<br>" + "<li>请输入您的用户名或密码。<li>"
        end if
        if founderr then exit sub
        ip = replace(request.servervariables("remote_addr"), "'", "")
        dim rs

        set rs = mesky.execute("select * from mesky_sitemanager where username='" & username & "'")
        if rs.eof and rs.bof then
            set rs = nothing
            founderr = true
            errmsg = errmsg + "<br>" + "<li>您输入的用户名和密码不正确或者您不是系统管理员。<br><li>请<a href=admin_login.asp>重新输入</a>您的密码。"
            exit sub
        else
            if trim(rs("password")) <> password then
                founderr = true
                errmsg = errmsg + "<br>" + "<li>您输入的用户名和密码不正确或者您不是系统管理员。<br><li>请<a href=admin_login.asp>重新输入</a>您的密码。"
                set rs = nothing
                exit sub
            else
            session("adminname") = rs("username")
            session("adminpass") = rs("password")
            session.timeout = 45
            mesky.execute ("update mesky_sitemanager set lastlogin= " & sqlnowstring & ",lastloginip='" & ip & "',lastactive=" & sqlnowstring & ",logins=logins+1 where username='" & username & "'")
            set rs = nothing
            call mesky.loadsetting()
            response.write "<script>location.href='" & mesky.setting(11) & "admin_index.asp'</script>"
            end if
        end if
    end sub
end class %>

申明:本教程内容由威凡网编辑整理并提供IT程序员分享学习,如文中有侵权行为,请与站长联系(QQ:254677821)!
上一节 下一节
相关教程  
其他教程  
ASP基础
应用技巧
数据库相关
ASP类
存储过程
FSO专栏
ASP其他

违法和不良信息举报中心】邮箱:254677821@qq.com
Copyright©威凡网 版权所有 苏ICP备2023020142号
站长QQ:254677821