Yojo网页设计

首页 新闻中心 网页教程 图形图像 设计欣赏 编程开发 程序教程 网站运营 数据库教程
·ASP教程·ASP.net教程·PHP教程·JSP教程·编程杂谈·AJAX·XML

您现在的位置: yojo网页设计 >> 编程开发 >> ASP教程 >> 正文

 

ASP类型个人网站与动网整合方法

更新时间:2007-11-18 19:32:50 文章来源:互联网 .

个人网站如有会员注册模块+动网论坛的话,那网站要与动网论坛系统整合,实现不同Web系统之间的用户信息同步更新、登录等操作就不是件容易的事了,虽然动网已提供有详细的"动网论坛系统Api接口开发人员指南",但像我这样的菜鸟一时半会可是参详不透的,汗。不甘心,在对其登录、验证等函数进行一番研究再加以测试后最终竟也小有所成,菜鸟也有菜鸟的办法,哈哈。

一、网站文件结构

wwwroot
  ┝ index.asp
  ┝ CheckUserLogin.asp
  ┕ bbs/

二、整合原理

对于同步更新实现不困难,整合主要问题就是难在同步登录,所以我们的重点都将放在讨论如何实现同步登录上。我的方法是将主站用户表整合至动网用户表Dv_User中(免去以后得更新两个库的麻烦),可按需要在Dv_User新增字段,并对bbs/login.asp和bbs/inc/Dv_ClsMain.asp做适当的修改;登录时将表单发至bbs/login.asp进行验证;主站根据动网登录成功后在Session记录的信息判断是否登录成功,并取得用户资料。

三、新增修改文件

1.index.asp code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>个人网站与动网整合(www.mzwu.com)</title>
</head>

<body>
<!--#include file="CheckUserLogin.asp" -->
<%
If CheckUserLogin Then
    Response.write("<a href=""bbs/logout.asp?back=1"">退出登陆</a><p></p>")
    Response.write("用户名:" & Request.Cookies("username") & "<br>")
    Response.write("性别:" & Request.Cookies("sex") & "<br>")
    Response.write("注册时间:" & Request.Cookies("joindate") & "<br>")
    Response.write("最后登录:" & Request.Cookies("lastlogin") & "<br>")
    Response.write("登录次数:" & Request.Cookies("userlogins") & "<br>")
    Response.write("浏览器类型:" & Request.Cookies("browser") & "<br>")
    Response.write("浏览器版本:" & Request.Cookies("version") & "<br>")
    Response.write("操作系统:" & Request.Cookies("platform") & "<br>")
Else
%>
<form id="form1" name="form1" method="post" action="bbs/login.asp?action=chk&back=1">
  用户名:
    <input name="username" type="text" id="username" size="10" />
    <br />
    密  码:
    <input name="password" type="password" id="password" size="10" />
    <input type="submit" name="Submit" value="登录" />
</form>
<%
End if
%>
<p></p><a href="bbs/">进入论坛</a>
</body>
</html>


2.CheckUserLogin.asp code:
<!--#Include File="bbs/inc/Dv_ClsMain.asp"-->
<%
Function CheckUserLogin()
    Dim Dvbbs,UserSession
    Const MsxmlVersion=".3.0"
    Set Dvbbs = New Cls_Forum
    Set UserSession=Server.CreateObject("msxml2.FreeThreadedDOMDocument"& MsxmlVersion)
    If UserSession.loadxml(Session(Dvbbs.CacheName & "UserID")&"") Then
        If UserSession.documentElement.selectSingleNode("userinfo/@userid").text<>"0" Then
            '在论坛登录成功
            CheckUserLogin = True
            '下边是用户一些信息的获取方法,可自行将其保存于Cookies或Session中便于使用:
            '用户ID      :  UserSession.documentElement.selectSingleNode("userinfo/@userid").text
            '用户名      :  UserSession.documentElement.selectSingleNode("userinfo/@username").text
            '生日        :  UserSession.documentElement.selectSingleNode("userinfo/@userbirthday").text
            '电子邮箱    :  UserSession.documentElement.selectSingleNode("userinfo/@useremail").text
            '性别        :  UserSession.documentElement.selectSingleNode("userinfo/@usersex").text  '0为女,1为男
            '注册时间    :  UserSession.documentElement.selectSingleNode("userinfo/@joindate").text
            '最后登录    :  UserSession.documentElement.selectSingleNode("userinfo/@lastlogin").text
            '登录次数    :  UserSession.documentElement.selectSingleNode("userinfo/@userlogins").text
            '金钱        :  UserSession.documentElement.selectSingleNode("userinfo/@userwealth").text
            '积分        :  UserSession.documentElement.selectSingleNode("userinfo/@userep").text
            '魅力        :  UserSession.documentElement.selectSingleNode("userinfo/@usercp").text
            '最后登录IP  :  UserSession.documentElement.selectSingleNode("userinfo/@userlastip").text
            '浏览器类型  :  UserSession.documentElement.selectSingleNode("agent/@browser").text
            '浏览器版本  :  UserSession.documentElement.selectSingleNode("agent/@version").text
            '操作系统    :  UserSession.documentElement.selectSingleNode("agent/@platform").text
            '来访IP      :  UserSession.documentElement.selectSingleNode("agent/@ip").text
            '举例应用:
            Response.Cookies("username") = UserSession.documentElement.selectSingleNode("userinfo/@username").text
            Response.Cookies("joindate") = UserSession.documentElement.selectSingleNode("userinfo/@joindate").text
            If UserSession.documentElement.selectSingleNode("userinfo/@usersex").text="0" Then
                Response.Cookies("sex") = "靓妹"
            Else
                Response.Cookies("sex") = "酷哥"
            End if
            Response.Cookies("lastlogin") = UserSession.documentElement.selectSingleNode("userinfo/@lastlogin").text
            Response.Cookies("userlogins") = UserSession.documentElement.selectSingleNode("userinfo/@userlogins").text
            Response.Cookies("browser") = UserSession.documentElement.selectSingleNode("agent/@browser").text
            Response.Cookies("version") = UserSession.documentElement.selectSingleNode("agent/@version").text
            Response.Cookies("platform") = UserSession.documentElement.selectSingleNode("agent/@platform").text
        Else
            '访问过论坛尚未登录,为来宾状态
            CheckUserLogin = False
        End if
    Else
        '未访问过论坛
        CheckUserLogin = False
    End if
    Set UserSession = nothing
    Set Dvbbs = nothing
End Function
%>

[1] [2] [3] 下一页


点击: 文章地址:http://www.518web.net/bckf/asp/10521.html

热门点击

友情链接首页文字链接要求:PR≥4,搜索引擎正常收录,开通一年以上,内容健康充实的站点!申请...

Copyright(C) 2005-2008 518web.net,All Rights Reserve
Email:yojo.x@msn.com | 在线QQ:2306380 53614197| [浙ICP备08009643号]