立即注册 找回密码

QQ登录

只需一步,快速开始

查看: 4454|回复: 0

[美化修改教程] PHP调用discuz登陆框实现外部登录

[复制链接]
发表于 2015-4-1 16:34:17 | 显示全部楼层 |阅读模式
道勤网-数据www.daoqin.net

亲注册登录道勤网-可以查看更多帖子内容哦!(包涵精彩图片、文字详情等)请您及时注册登录-www.daoqin.net

您需要 登录 才可以下载或查看,没有账号?立即注册

x
利用php调用discuz登录框方法有很多种,最常用的就是直接使用iframe方式调用了,还有就是直接在php页面中调用了,下面小编来给大家总结一些常用的方法。
方法一,直接使用iframe调用一个加了discuz登录功能的页面
  1. <span style="color: rgb(0, 0, 0); font-family: Simsun; line-height: 26px; background-color: rgb(255, 255, 255);"> <iframe src="/login.html" style="width:100%; height:32px" scrol</span><a  target="_blank" style="font-size: 15px; color: rgb(45, 100, 179); font-family: Simsun; line-height: 26px; background-color: rgb(255, 255, 255);">ling</a><span style="color: rgb(0, 0, 0); font-family: Simsun; line-height: 26px; background-color: rgb(255, 255, 255);">="no" frameborder="0" ></iframe></span>
复制代码
login.html代码
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  5. <title> c-gd.com-登录</title>
  6. <style type="text/css">
  7. <!--
  8. * {
  9. margin:0;
  10. padding:0;
  11. }
  12. body {
  13. font: normal 12px Arial, Helvetica, Sans-Serif, "宋体";
  14. line-height: 160%;
  15. text-align:left;
  16. color: #3a3a3a;
  17. margin:0;
  18. padding:0;
  19. }
  20. img {
  21. border:0;
  22. }
  23. ul, li {
  24. padding:0;
  25. margin:0;
  26. list-style:none;
  27. }
  28. a {
  29. text-decoration: none;
  30. color:#3a3a3a;
  31. }
  32. a:hover {
  33. color: #C00;
  34. }
  35. .banner {
  36. margin-bottom:1px;
  37. height:59px;
  38. }
  39. .denglu {
  40. height:31px;
  41. border-bottom:1px solid #FFF;
  42. background:#e7e3e4;
  43. color:#7b797a;
  44. }
  45. .denglu a {
  46. color:#7b797a;
  47. text-decoration:none;
  48. }
  49. .denglu a:hover {
  50. color:#C00;
  51. text-decoration:underline;
  52. }
  53. .denglu .box01 {
  54. margin-left:30px;
  55. float:left;
  56. width:224px;
  57. line-height:30px;
  58. height:31px;
  59. }
  60. .denglu .box02 {
  61. width:433px;
  62. float:left;
  63. color:#000;
  64. text-align:right;
  65. }
  66. .denglu .box02 input {
  67. border:1px #c5c3c3 solid;
  68. height:20px;
  69. width:88px;
  70. background:#FFF;
  71. line-height:20px;
  72. margin-top:5px;
  73. }
  74. .denglu .box02 .button {
  75. background:url(/static/image/common/img01.gif) no-repeat;
  76. width:50px;
  77. height:21px;
  78. border:0;
  79. color:#4b4b4b;
  80. margin:0 5px;
  81. font-size:12px;
  82. line-height:20px;
  83. }
  84. .denglu .box03 {
  85. float:right;
  86. line-height:30px;
  87. height:31px;
  88. margin-right:15px;
  89. }
  90. .denglu .box03 .font1 {
  91. margin-left:20px;
  92. }
  93. .denglu .box03 .font2 {
  94. margin-left:10px;
  95. background:url(/static/image/common/icon03.jpg) left center no-repeat;
  96. padding-left:8px;
  97. margin-left:40px;
  98. }
  99. -->
  100. </style>
  101. <script type="text/javascript">
  102. function checkform(){
  103. if(document.getElementById('username').value==''){
  104.   alert('请输入用户名');
  105.   return false;
  106. }
  107. if(document.getElementById('password').value==''){
  108.   alert('请输入密码');
  109.   return false;
  110. }
  111. return true;
  112. }

  113. function showDate()
  114. {
  115. var d = new Date();  
  116. document.write("<div class='date_div'>"+d.getYear()+"年"+(d.getMonth()+1)+"月"+d.getDate()+"日");
  117. switch(d.getDay())
  118. {
  119. case 0:
  120.   document.write("  星期日");
  121.   break;
  122. case 1:
  123.   document.write("  星期一");
  124.   break;
  125. case 2:
  126.   document.write("  星期二");
  127.   break;
  128. case 3:
  129.   document.write("  星期三");
  130.   break;
  131. case 4:
  132.   document.write("  星期四");
  133.   break;
  134. case 5:
  135.   document.write("  星期五");
  136.   break;
  137. case 6:
  138.   document.write("  星期六");
  139.   break;
  140. }
  141. document.write("</div>");
  142. }
  143. </script>
  144. </head>
  145. <body>
  146. <div id="header">
  147.   <!--登录-->
  148.   <div class="denglu">
  149.     <div class="box01">
  150. <script language="JavaScript" type="text/JavaScript">
  151. showDate();
  152. </script>    </div>
  153.          <form method="post" action="/bbs/member.php?mod=logging&action=login&loginsubmit=yes&infloat=yes" onsubmit="return checkform();">
  154.      <div class="box02">
  155.      用户名:<input type="text" name="username" id="username" />
  156.          密码:<input type="password" name="password" id="password"  />
  157.              <input type="hidden" name="quickforward" value="yes" />
  158.                <input type="hidden" name="handlekey" value="ls" />
  159.                <input type="hidden" name="iflogin" value="plus.php?mod=iframelogin" />
  160.       <span>
  161.       <input name="input" type="submit"  class="button" value="登录" style="cursor:pointer" />
  162.       </span>
  163.       <span>
  164.       <input name="input" type="button"  class="button" value="注册" style="cursor:pointer" onclick="window.open('/bbs/member.php?mod=register')"/>
  165.       </span>
  166.       </div>
  167.       </form>
  168.    
  169.     <div class="box03">
  170.     <span class="font2"><a onclick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.111cn.net');" href="javascript:;">设为首页</a></span>
  171.     <span class="font1"><a href="/" target="_parent">中文</a> | <a href="#"  target="_parent">English</a></span>
  172.    
  173.     </div>

  174.    
  175.   </div>
  176. </div>
  177. </body>
  178. </html>
复制代码

方法二,利用php方式调用了

在自定义的PHP页面里加入discuz登陆框。PHP如何调用discuz登陆框。

  1. <?php
  2. error_reporting(0);
  3. require 'source/class/class_core.php';
  4. $discuz = & discuz_core::instance();
  5. $discuz->init();
  6. if (empty($_G['uid'])) {
  7. ?>

  8. <form target="_blank" action="member.php?mod=logging&action=login&loginsubmit=yes&infloat=yes" method="post" name="form2" onSubmit="return check()">
  9. <span>用户名:<input name="username" type="text" id="textfield2" size="13" tabindex="1" value="请输入用户名" onFocus="this.value='';" onBlur="if(this.value==''){this.value='请输入用户名';}">
  10. 密码:<input name="password" type="password" id="password" size="12">
  11. <input type="submit" name="button2" id="button2" value="登录" onClick="setTimeout('window.location.reload()', 2000)">
  12. <a href="member.php?mod=register" target="_blank">注册</a>
  13. <a href="member.php?mod=logging&action=login&viewlostpw" target="_blank">找回密码</a>
  14. <input type="hidden" name="referer" value="/" /></span>
  15. </form>

  16. <?php } else { ?>

  17. <div>
  18. 尊敬的<a href="home.php?mod=space&uid=<?php echo $_G['uid']; ?>&do=profile" target="_blank"><? echo $_G['username']; ?></a>,欢迎您光临!  | <a href="home.php?mod=space&do=thread&view=me" target="_blank">我的帖子</a> |  <a href="home.php" target="_blank">个人中心</a> |  <a href="member.php?mod=logging&action=logout&formhash=<? echo FORMHASH;?>" target="_blank" onClick="setTimeout('window.location.reload()', 2000)">退出登陆</a>
  19. </div>

  20. <?php }?>
复制代码

方法三:discuz登陆框是ajax调用的,一开始在firebug下看到了调用了接口:

  1. /member.php  ?mod=logging&action=login&infloat=yes&handlekey=login&inajax=1&ajaxtarget=fwin_content_login
复制代码

这返回的是一个xml的内容,其中就一个结点root,里面会根据本地的cookies判断是否登录了论坛,如果没有登陆

里面的内容就是一段form登陆表单。如果登陆了里面就是一段登陆后的信息。然后将ajax请求中的css保存到本

地。能够实现登陆框调用。登陆框中有一个hidden的input name=‘reffer’ 这里面的value值是来路链接.不过要是

论坛程序里的。比如将这个连接换成h/home.php?mod=spacecp&ac=blog这样登陆完后会

自动跳转到发博客的页面。可以实现一键发帖功能。

代码如下:

  1. ?php  
  2. $login = file_get_contents("/member.php?  
  3. mod=logging&action=login&infloat=yes&handlekey=login&inajax=1&ajaxtarget=fwin_content_login");
  4. require_once('SofeeXmlParser.php');//xml解析类 博客里搜索xml有相关介绍  
  5. $xml = new SofeeXmlParser();  
  6. $xml->parseString($login);  
  7. $tree = $xml->getTree();  
  8. $login = str_replace("member.php","h/member.php",$tree["root"]["value"]);  
  9. $login = str_replace("h/./","h/home.php?  
  10. mod=spacecp&ac=blog",$login);//跳转到发帖页面  
  11. $login = preg_replace('/<h3 class="flb">(.*)</h3>/i','',$login);  
  12. var_dump($login);  
  13. exit();  
  14. $login = iconv('utf-8','gbk',$login);  
  15.    
  16. echo $login;  
  17. ?>
复制代码


道勤主机提供365天*24小时全年全天无休、实时在线、零等待的售后技术支持。竭力为您免费处理您在使用道勤主机过程中所遇到的一切问题! 如果您是道勤主机用户,那么您可以通过QQ【792472177】、售后QQ【59133755】、旺旺【诠释意念】、微信:q792472177免费电话、后台提交工单这些方式联系道勤主机客服! 如果您不是我们的客户也没问题,点击页面最右边的企业QQ在线咨询图标联系我们并购买后,我们为您免费进行无缝搬家服务,让您享受网站零访问延迟的迁移到道勤主机的服务!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

道勤网- 推荐内容!上一条 /2 下一条

!jz_fbzt! !jz_sgzt! !jz_xgzt! 快速回复 !jz_fhlb! !jz_lxwm! !jz_gfqqq!

关于我们|手机版|小黑屋|地图|【道勤网】-www.daoqin.net 软件视频自学教程|免费教程|自学电脑|3D教程|平面教程|影视动画教程|办公教程|机械设计教程|网站设计教程【道勤网】 ( 皖ICP备15000319号-1 )

GMT+8, 2024-9-20 16:41

Powered by DaoQin! X3.4 © 2016-2063 Dao Qin & 道勤科技

快速回复 返回顶部 返回列表