Discuz Forum User Login Background program code _php instance

Source: Internet
Author: User
Fortunately, the user login here through a small method can be implemented and the Forum synchronization. You can use a Passport interface.
This is the data I collated, for reference only.
Login to pass two values come on line (username and password);
Copy Code code as follows:

<?php
Session_Start ();
Define (' Norobot ', 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= ' $onlineip ' and Count>= ' $seccodedata [Loginfailedcount] ' and $timestamp-lastupdate<=900 '), 0);
}
$discuz _uid = 0;
$discuz _user = $discuz _PW = $discuz _secques = $md 5_password = ';
$member = Array ();
$loginperm = Logincheck ();
if (! $loginperm) {
ShowMessage (' login_strike ');
}
$secques = Quescrypt ($questionid, $answer);
if (Isset ($loginauth)) {
$field = ' username ';
$password = ' verified ';
List ($username, $md 5_password) = daddslashes (Explode ("T", Authcode ($loginauth, ' DECODE '), 1);
} else {
$MD 5_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 Discu Z_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 if the login is correct
if ($member [' Password ']!= $md 5_password) {
echo "You have entered an incorrect username or password!";
Exit ();
}
By executing the program below
Extract ($member);
$discuz _userss = $discuz _user;
$discuz _user = addslashes ($discuz _user);
if ($allowinvisible && $loginmode = = ' invisible ') | | $loginmode = = ' normal ') {
$db->query ("UPDATE {$tablepre}members SET invisible= '". $loginmode = = ' invisible '? 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", ' ENCODE '), $cookietime);
$sessionexists = 0;
Updatesession ()//Update forum Userpass data
echo "{' Action ': ' Ture '}";//This is the data you want to 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.