·您当前的位置:首页 > 技术教程 > PHP教程 >

[php]discuz论坛登陆信息判断外部调用的用法实例(2)

时间:2015-08-05 16:45酷播
方法2:在网上找到的方法 ,很好用。直接上代码: ?php require 'source/class/class_core.php'; $discuz = discuz_core::instance(); $discuz-init(); //以上是调用discuz公共执行类等核心代码 ? ?php if (empty($

方法2:在网上找到的方法 ,很好用。直接上代码:
<?php
require 'source/class/class_core.php';
$discuz = & discuz_core::instance();
$discuz->init(); //以上是调用discuz公共执行类等核心代码
?>
<?php if (empty($_G['uid'])) {?>
<form action="http://localhost/bbsx2/member.php?
mod=logging&action=login&loginsubmit=yes&infloat=yes" method="post" name="form2" onSubmit="return check()" >
用户名:<input name="username" type="text" id="textfield2" size="13" tabindex="1" value="请输入用户名" onFocus="this.value='';" onBlur="if(this.value==''){this.value='请输入用户名';}">
密码:<input name="password" type="password" id="password" size="12"> <input class="input_on1111" type="submit" name="button2" id="button2" value="登录">
<a href="/bbs/member.php?mod=register"> 注册</a>
<a href="http://localhost/bbsx2/member.php?mod=logging&action=login&viewlostpw">找回密码</a></form>
<?php }
else { ?><div align="right">欢迎您:<a href="http://localhost/bbsx2/space-uid-<?php echo $_G['uid']; ?>.html" class="yellow">
<?php echo $_G['username']; ?></a> <a href="http://localhost/bbsx2/home-space-do-thread-view-me.html">我的帖子</a>
<a href="http://localhost/bbsx2/home.php">个人中心</a>
<a href="http://localhost/bbsx2/member-logging-action-logout-formhash-<?php echo FORMHASH;?>.html">退出登陆</a></div><?php }?>
上面代码是因为discuz用了伪静态,或者你没有使用的话,请修改成以下代码:
<a href="http://localhost/bbsx2/home.php?mod=space&do=thread&view=me">我的帖子</a>
<a href="http://localhost/bbsx2/member.php?mod=logging&action=logout&formhash=<?php echo FORMHASH;?>">退出登陆</a>
01 <?php
02 require 'source/class/class_core.php';
03 $discuz = & discuz_core::instance();
04 $discuz->init(); //以上是调用discuz公共执行类等核心代码
05 ?>
06 <?php if (empty($_G['uid'])) {?>
07 <form action="http://localhost/bbsx2/member.php?
08 mod=logging&action=login&loginsubmit=yes&infloat=yes" method="post" name="form2" onSubmit="return check()" >
09 用户名:<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"> <input class="input_on1111" type="submit" name="button2" id="button2" value="登录">
11 <a href="/bbs/member.php?mod=register"> 注册</a>
12 <a href="http://localhost/bbsx2/member.php?mod=logging&action=login&viewlostpw">找回密码</a></form>
13 <?php }
14 else { ?><div align="right">欢迎您:<a href="http://localhost/bbsx2/space-uid-<?php echo $_G['uid']; ?>.html" class="yellow">
15 <?php echo $_G['username']; ?></a> <a href="http://localhost/bbsx2/home-space-do-thread-view-me.html">我的帖子</a>
16 <a href="http://localhost/bbsx2/home.php">个人中心</a>
17 <a href="http://localhost/bbsx2/member-logging-action-logout-formhash-<?php echo FORMHASH;?>.html">退出登陆</a></div><?php }?>
18 上面代码是因为discuz用了伪静态,或者你没有使用的话,请修改成以下代码:
19 <a href="http://localhost/bbsx2/home.php?mod=space&do=thread&view=me">我的帖子</a>
20 <a href="http://localhost/bbsx2/member.php?mod=logging&action=logout&formhash=<?php echo FORMHASH;?>">退出登陆</a>

这种方法可以判断用户登陆状态.本来在辅导员博客程序用这种方法最好,不过由于博客程序是smarty做的,将这段程序用了很多种方法引入smarty中不兼容。

热门文章推荐

请稍候...

保利威视云平台-轻松实现点播直播视频应用

酷播云数据统计分析跨平台播放器