php下获取Discuz论坛登录用户名、用户组、用户ID等信息的实现代_PHP

WBOY
Release: 2016-06-01 12:17:56
Original
1148 people have browsed it

这里讲一个简单的方法,直接使用discuz的include/common.inc.php来登录。
复制代码 代码如下:
include_once("../discuz/include/common.inc.php");
$CTDF_USERINFO = array();
$CTDF_USERINFO["sid"] = $sid;
$CTDF_USERINFO["uid"] = $discuz_uid;
$CTDF_USERINFO["user"] = $discuz_user;
if ($discuz_uid == 0)
{
$CTDF_USERINFO["user"] = "guest_" . $sid;
}
$CTDF_USERINFO["groupid"] = $groupid;
/**
* clear discuz variables
*/
$reserved_arr = array("GLOBALS", "_POST", "_GET", "_COOKIE", "_FILES", "_SERVER", "_ENV", "_REQUEST", "CTDF_USERINFO", "reserved_arr");
foreach ($GLOBALS as $key => $value)
{
if (!in_array($key, $reserved_arr))
{
unset($GLOBALS[$key]);
}
}
unset($reserved_arr, $value);

将上面这段代码放在任何程序的开头处,其目的是不影响自定义变量的使用。这样就将登录信息读取到$CTDF_USERINFO数组中了。

还是这个比较简单哦,找了很久,这次就爽了

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!