Code of the background program for discuz forum user login

Source: Internet
Author: User

Fortunately, you can use a small method to synchronize with the Forum by logging on here. You do not need the passport interface.
This is my data for reference only.
Log on and pass two values (username and password );
Copy codeThe Code is as follows:
<? Php
Session_start ();
Define ('nobot ', TRUE );
Define ('curscript', 'logging ');
Require_once './include/common. inc. php ';
Require_once DISCUZ_ROOT. './include/misc. func. php ';
If ($ action = 'login '){
$ Field = $ loginfield = 'uid '? 'Uid': 'username ';
// Get secure code checking status (pos.-2)
$ Seccodecheck = substr (sprintf ('% 05b', $ seccodestatus),-2, 1 );
If ($ seccodecheck & $ seccodedata ['loginfailedcount']) {
$ Seccodecheck = $ db-> result ($ db-> query ("SELECT count (*) FROM {$ tablepre} failedlogins WHERE ip address = '$ onlineip' AND count> =' $ seccodedata [loginfailedcount] 'AND $ timestamp-lastupdate <= 900 "), 0 );
}
$ Discuz_uid = 0;
$ Discuz_user = $ discuz_pw = $ discuz_secques = $ md5_password = '';
$ Member = array ();
$ Loginperm = logincheck ();
If (! $ Loginperm ){
Showmessage ('login _ strike ');
}
$ Secques = quescrypt ($ questionid, $ answer );
If (isset ($ loginauth )){
$ Field = 'username ';
$ Password = 'verified ';
List ($ username, $ md5_password) = daddslashes (explode ("\ t", authcode ($ loginauth, 'decode'), 1 );
} Else {
$ Md5_password = md5 ($ password );
$ Password = preg_replace ("/^ (. {". round (strlen ($ password)/4). "}) (. + ?) (. {". Round (strlen ($ password)/6)."}) $/s "," \ 1 *** \ 3 ", $ password );
}
$ Query = $ db-> query ("SELECT m. uid AS discuz_uid, m. username AS discuz_user, m. password AS discuz_pw, m. secques AS discuz_secques,
M. adminid, m. groupid, m. styleid AS styleidmem, m. lastvisit, m. lastpost, u. allowinvisible
FROM {$ tablepre} members m left join {$ tablepre} usergroups u USING (groupid)
WHERE m. $ field = '$ username '");
$ Member = $ db-> fetch_array ($ query );
// Determine whether the logon is correct
If ($ member ['Password']! = $ Md5_password ){
Echo "the user name or password you entered is incorrect! ";
Exit ();
}
// Execute the following program
Extract ($ member );
$ Discuz_userss = $ discuz_user;
$ Discuz_user = addslashes ($ discuz_user );
If ($ allowinvisible & $ loginmode = 'invisable') | $ loginmode = 'normal '){
$ Db-> query ("UPDATE {$ tablepre} members SET invisible = '". ($ loginmode = 'invisable '? 1: 0). "'where uid = '$ member [discuz_uid]'", 'unbuffered ');
}
$ Styleid = intval (empty ($ _ POST ['styleid'])? ($ Styleidmem? $ Styleidmem:
$ _ DCACHE ['settings'] ['styleid']): $ _ POST ['styleid']);
$ Cookietime = intval (isset ($ _ POST ['cookietime'])? $ _ POST ['cookietime']:
($ _ DCOOKIE ['cookietime']? $ _ DCOOKIE ['cookietime']: 0 ));
Dsetcookie ('cookietime', $ cookietime, 31536000 );
Dsetcookie ('auth', authcode ("$ discuz_pw \ t $ discuz_secques \ t $ discuz_uid", 'encoding'), $ cookietime );
$ Sessionexists = 0;
Updatesession (); // update the Forum USERPASS data
Echo "{'action': 'ture '}"; // The data to be output.
Print_r ($ _ DSESSION );
Echo $ discuz_userss;
}
?>

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.