Home >Backend Development >PHP Tutorial >discuz x1.5 Introduction to DISCUZ without a pass login page 1/2

discuz x1.5 Introduction to DISCUZ without a pass login page 1/2

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-29 08:39:00901browse

Introduction to DISCUZ login without a pass
DISCUZ is the most commonly used forum in China. Although it has a pass for everyone to connect to, the actual unification of users is still very poor. Two user tables are often created, which is not conducive to registration. And management, the second waste of database.
I recently worked on a project that also used DISCUZ, so I studied the login of DISCUZ and basically completed the synchronous login. If you are interested, you can research it.
No more nonsense. If you write your own system, you can directly use the DISCUZ public file and directly reference include/common.inc.php. This is the simplest. As long as you reference this file, $discuz_uid will be yours. User ID, $discuz_user is your username,
If you use your own public file, you need to extract two functions. In global.func.php, there are two functions
Dsetcookie, and authcode. If you don’t If you are too lazy, copy a function clearcookies. The first one is DISCUZ's own function to create COOKIE, the second one is DISCUZ's reversible encryption function, and the third one is the clear COOKIE function. I put it in my own FUNC.PHP file. Okay
Okay, let’s start writing the method of creating and identifying COOKIE
function lgoin($array)
{
$username = $array['username'];
$password = $array['password'];
$ sql = "SELECT `uid`,`password`,`secques` FROM `cdb_members` WHERE
`username`='$username' and `password`=md5('$password')";
try {
$rs = $this -> _db -> query($sql);
}catch (Exception $e){
exit("Query error, error message: ".$e->getMessage());
return 0;
}
$row = $this -> _db -> fetch($rs); //Check whether the logged in username and password are correct
if($row){
dsetcookie('sid','',-2423234234 ); // Log out sid
$secques = $row['secques'];
$uid = $row['uid'];
$formPassword = $row['password'];
dsetcookie('auth', authcode("$formPasswordt$secquest$uid", 'ENCODE','123'), '0');
return 1;
}else{
return 2;
}
}
This is a login function, no nonsense Having said that, let’s talk about the key parts directly. After querying and obtaining the information, (if the username and password are correct) we get 3 pieces of information, UID, PASSWORD, and SECQUES. These three are needed by DISCUZ to establish COOKIE. The first is the user ID, the second is the encrypted password, and the third is the encrypted answer to the question (used even if it is not set). DISCUZ needs to prompt questions and answers, but we do not need to log in. , so I checked him out directly here. dsetcookie('auth', authcode("$formPasswordt$secquest$uid", 'ENCODE','123'), '0');
This sentence is to establish the user's COOKIE. Needless to say anything else, please pay attention to this sentence '123', you must pay attention to this place. This is the KEY set during encryption. It needs to be the same as your DISCUZ, so there are three places that must be unified. One is global.func.php, and the other is copied by yourself. The authcode function, and when you use authcode. You should be able to log in to the forum at this time. If you cannot log in, please see below

Current page 1/2 12Next page

The above is the introduction of discuz x1.5 on page 1/2 of the introduction to DISCUZ login without a pass, including the content of discuz x1.5. I hope it will be helpful to friends who are interested in PHP tutorials.

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