首页  韩国资源  酷站加油  我的展厅  设计名站  古典元素  推荐下载  设计欣赏  每周专访  招募精英  人才专区  网页教程  平面设计  编程开发  设计竞赛
当前位置:首页 > 编程开发 > ASP教程 > ASP基础教程 > 正文
ASP类型个人网站与动网整合方法
来源:木子屋 作者:dnawo 2007年10月09日 09:20 网友评论:0条 点击:
个人网站如有会员注册模块+动网论坛的话,那网站要与动网论坛系统整合,实现不同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] 下一页 尾页
上一篇:什么造成字段中没有值?   下一篇:用ASP将数据库中的数据直接导出到EXCEL表中
收藏此页】【打印】【关闭
 相关文章  我要点评
·视频网站为何集体受挫
·格鲁吉亚Gurieli CSS网站作品欣赏
·澳大利亚Bugx0r几款简洁风格页面设计(二)
·webdesigner1921精彩网站作品(六)
·美国NorthernDesign简洁风格网站作品(二)
·波兰neilan web作品整理
·挪威ECP-Pro精彩网站界面作品(二)
·视频网站守候八年周期 金融海啸下集体瘦身

免责声明:本站刊载此文不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。对本文有任何异议,请联络:68design#163.com
转载要求:作者及来源信息必需保留。转载之图片、文件,链接请不要盗链到本站,且不准打上各自站点的水印。



关于我们 | 在线反馈 | 广告报价 | 友情链接 | 联系我们 | 免责声明 | 在线投稿 | 网站地图
Copyright © 2003-2007 68design.net, All Rights Reserve 【找网页设计师,当然上网页设计师联盟】