基本思想: 最简单化设计,采用一个页面内2个iframe来解决注册、登陆、修改密码的同步。 phpBB的帐号系统和原系统得完全独立,因此不需要任何修改
在登录前自动先注销论坛帐号
注册: <IFRAME name="register" src="register.php" width=100% height=300></IFRAME> <IFRAME name="bbsregister" src="phpBB2/profile.php?mode=register&agreed=true" width=1px height=1px></IFRAME>
Register.php 原系统得注册程序 原系统注册提交按钮 <input type="button" value="提交" onClick="checkForm(this.form)">
function checkForm(form) { parent.bbsregister.document.forms[0].username.value=form.username.value; parent.bbsregister.document.forms[0].email.value=form.email.value; parent.bbsregister.document.forms[0].new_password.value=form.password.value; parent.bbsregister.document.forms[0].password_confirm.value=form.password.value; parent.bbsregister. document.forms[0].submit(); document.form.submit(); // un-comment to submit form }
登录成功后,系统跳出原来的iframe回到主iframe echo "<script>parent.location='***.php'</script>";
phpBB2的profile.php?mode=register&agreed=true中由于存在name=submit的submit按钮,所以会影响submit()函数的执行。需要修改模板文件 template/profile_add_body.tpl <input type="hidden" name="submit1" value="{L_SUBMIT}" class="mainoption" /> <input type="submit" name="submit2" value="{L_SUBMIT}" class="mainoption" /> 将原来的name=submit改为name=submit2,由于执行submit()函数的时候submit按钮的值并不会提交,所以再增加一个hidden的name=submit1,方便后台判断 Include/usercp_register.php 所有的$HTTP_POST_VARS['submit']替换为$HTTP_POST_VARS['submit1']
这样在name=submit1的hidden值POST以后系统即会注册
登录 <IFRAME name="login" src="login.php" width=100% height=300></IFRAME> <IFRAME name="bbslogin" src="phpBB2/login.php" width=1 height=1></IFRAME>
login.php <input type="button" value="登录" onclick="checkLogin(this.form)">
function checkLogin(form) { if (!checkUserName(form)) return; if (!checkPass(form)) return; parent.bbslogin.document.forms[0].username.value=form.username.value; parent.bbslogin.document.forms[0].password.value=form.password.value; parent.bbslogin.document.forms[0].submit(); document.form.submit(); // un-comment to submit form }
在login.php提交到验证后,跳出iframe到顶级窗口 echo "<script>parent.location='***.php'</script>";
由于phpBB2登录模块默认目标为_top,所以要修改模板文件 Template/login_body.tpl <form action="{S_LOGIN_ACTION}" method="post" target="_top">为 <form action="{S_LOGIN_ACTION}" method="post" target="_self">
同时此模板的submit按钮name=login,所以不必另行处理。
退出phpbb2用户session logout.php 在原来的注销登录文件中除了原有的语句外,加入 <IFRAME name="bbsregister" src="phpBB2/login.php?logout=true" width=1px height=1px></IFRAME> okgo("退出系统成功","index.php");
即可同时注销phpBB2帐号
当然在修改用户密码、删除用户的时候也要作同步动作,同时在phpBB2的程序中也要禁止用户进行修改密码、注册等行为,确保这些帐号修改只能在主用户表进行。 
|