Discuz x1.5 about Discuz do not pass the landing content introduction 1th/2 page

Source: Internet
Author: User
About Discuz do not use the pass to login content introduction
Discuz is China's most commonly used forum, although he has a pass for everyone to connect, but in fact the user's unity is very bad, often to build two user tables, the first is not conducive to registration and management, the second waste database.
Recently do a project is also used Discuz, so the study of Discuz Landing, basically completed a synchronous landing. If you are interested, you can look into it.
Other No nonsense, if you write your own system, you can directly use Discuz public files, direct reference include/common.inc.php just fine, 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 public 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 discuz own function of building a cookie, the second is a reversible cryptographic function of discuz, and the third is to clear the cookie function, I put it in my own func.php file.
Okay, let's start writing a way to create 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 = Query ($sql), _db, $this
}catch (Exception $e) {
Exit ("Query error, error message:". $e->getmessage ());
return 0;
}
$row = Fetch ($RS), _db, $this Query the login user name and password is correct
if ($row) {
Dsetcookie (' Sid ', ',-2423234234); Log out 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 does not say, directly say the key part of it, after the query, when the information, (user name and password is correct) we obtained 3 information, Uid,password, and Secques, these three are discuz to establish a cookie need to use, The first is the user ID, the second is the password after the encryption, the third is the answer to answer the question after the encryption (even if there is no setting to use), Discuz is the need to prompt questions and answers, and we do not need to login, so I found him here directly. Dsetcookie (' auth ', Authcode ("$formPassword \t$secques\t$uid", ' ENCODE ', ' 123 '), ' 0 ');
This is to create a user's cookie, needless to say, please note that the phrase ' 123 ', this place must be aware that this is the encryption of the key set, you need to be here and you discuz, so there are three places must be unified, One is global.func.php, one is your own copy of the Authcode function, and you are using Authcode. This time the forum should be able to login, if not login, please see below

Current 1/2 Page 12 next page

The above describes the Discuz x1.5 about Discuz do not have access to the content of the 1th/2 page, including the Discuz x1.5 aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.