Discuz! Passport 通行证整合(5)


'=====================================================
'=================异或操作============================
'=====================================================
function mxor(chrb1,chrb2)
        if chrb1<>"" and chrb2 <>"" then
        mxor=chrb(ascb(chrb1) xor ascb(chrb2))
        end if       
end function


Function StrLength(str)
        ON ERROR RESUME NEXT
        Dim WINNT_CHINESE
        WINNT_CHINESE    = (len("中国")=2)
        If WINNT_CHINESE Then
                Dim l,t,c
                Dim i
                l=len(str)
                t=l
                For i=1 To l
                        c=asc(mid(str,i,1))
                        If c<0 Then c=c+65536
                        If c>255 Then
                                t=t+1
                        End If
                Next
                strLength=t
        Else
                strLength=len(str)
        End If
        If err.number<>0 Then err.clear
End Function

%>

2.文件 login.asp
<!--#include file="md5.asp"-->
<!--#include file="base64.asp"-->
<!--#include file="discuz_passport.asp"-->
<%
'asp的整合方法已更新,,中文注册乱码问题已解决
'================================================================
'=====================用法示例==疑问加我QQ:2666556===============
'================================================================
dim PassportKey,YourAspWeb_Url,DiscuzBbs_Url
PassportKey="1234567890"  '这里换成你discuz论坛通行证设置的passportkey
YourAspWeb_Url=""  '这里换成你的主页绝对地址或相对地址
DiscuzBbs_Url=":8080/discuz/"          '这里换成你的discuz论坛绝对地址或相对地址

select case request.QueryString("act")
        case "login"   call login()
        case "logout"  call logout()
end select

if request.Cookies("username")<>"" then
        dim str
        str=request.Cookies("username") & " 你好 你已登陆成功" &_
    " <a href=""https://www.jb51.net/t3.asp?act=logout"">点击这里退出登陆</a>" &_
    " <a href="""& DiscuzBbs_Url & """>点击这里访问论坛</a><br>"
    response.Write(str)
end if

function logout()
        dim auth,forward,verify
        auth=request.Cookies("auth")       
        response.Cookies("username")=""
        response.Cookies("auth")=""       
        forward=request.QueryString("forward")
        if forward="" then forward=YourAspWeb_Url                                         
        verify = md5("logout"& auth & forward & PassportKey ,32)
        auth=server.URLEncode(auth)
        forward=server.URLEncode(forward)
        response.Redirect(DiscuzBbs_Url & "api/passport.php?action=logout&auth=" & auth & "&forward=" & forward & "&verify=" & verify)
end function

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/a6b433df30aff4795dbf0d07a5abf20e.html