Home  >  Article  >  Backend Development  >  Implementation code to obtain Discuz forum login user name, user group, user ID and other information under PHP_PHP tutorial

Implementation code to obtain Discuz forum login user name, user group, user ID and other information under PHP_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:32:40982browse

Here is a simple method, directly use include/common.inc.php of discuz to log in.

Copy code The code is as follows:

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);

Put the above code in At the beginning of any program, the purpose is not to affect the use of custom variables. This will read the login information into the $CTDF_USERINFO array.

This is relatively simple. I’ve been looking for it for a long time and I’m happy with it this time.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/322759.htmlTechArticleHere is a simple method, directly use discuz’s include/common.inc.php to log in. Copy the code The code is as follows: include_once("../discuz/include/common.inc.php"); $CTDF_USERINFO...
Statement:
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