About Discuz without a pass landing content introduction
Discuz is the most commonly used forum in China, although he has a pass for everyone to connect, but in fact, the unity of the user is still very bad, often to create two user table, the first is not conducive to registration and management, the second waste of the database.
Recently do a project is also the use of discuz, so the study of Discuz Landing, basically completed the synchronous landing. If you are interested, you can study it.
Other than nonsense, if you write your own system, you can directly use discuz Common files, direct reference include/common.inc.php is good, so the simplest, as long as the reference to this file, $discuz _uid is your user ID, $discuz _ User is your username,
If you use your own common files, you need to extract two functions, in global.func.php, there are two functions
Dsetcookie, and Authcode, if you're not lazy. In copying a function clearcookies, the first one is to discuz its own function of building cookies, the second is the reversible cryptographic function of discuz, and the third is to clear the cookie function, I put it in my own func.php file.
All right, let's start with a way to build and identify cookies.
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); Query login username and password is correct
if ($row) {
Dsetcookie (' Sid ', ',-2423234234); Log off SID
$secques = $row [' secques '];
$uid = $row [' uid '];
$formPassword = $row [' Password '];
Dsetcookie (' auth ', Authcode ("$formPassword \t$secques\t$uid", ' ENCODE ', ' 123 '), ' 0 ');
return 1;
}else{
return 2;
}
}
This is a login function, nonsense not to say, directly say the key part of it, after the query, when the information, (username and password correct) we get 3 information, Uid,password, and Secques, these three are discuz build cookies need to use, The first is the user ID, the second is the password after encryption, the third is the answer answer after encryption (even if there is no setting to use), Discuz is required to prompt questions and answers, and we do not need to log on, so I have to directly check him out. Dsetcookie (' auth ', Authcode ("$formPassword \t$secques\t$uid", ' ENCODE ', ' 123 '), ' 0 ');
This sentence is to create a user's cookie, the other needless to say, please pay attention to this sentence ' 123 ', this place must pay attention to, this is the encryption when the key is set, is you here and you need to discuz the same, so there are three places must be unified, One is global.func.php, one is the Authcode function you copied out of yourself, and that is when you use Authcode. This time the forum should be able to log in, if not login, please see below
Current 1/2 page
12 Next read the full text