程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> 關於PHP編程 >> discuz論壇 用戶登錄 後台程序代碼

discuz論壇 用戶登錄 後台程序代碼

編輯:關於PHP編程

還好,用戶登錄這裡通過一個小小的方法可以實現和論壇同步了.可以不用passport接口.
這是我整理的數據,僅供參考.
登錄傳兩值過來就行(username和password);
復制代碼 代碼如下:
<?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 = $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);
//判斷登錄是否正確
if($member['password']!=$md5_password){
echo "您輸入的用戶名或密碼錯誤!";
exit();
}
//通過就執行下邊的程序
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();//更新論壇USERPASS數據
echo "{'action':'ture'}";//這裡是您要輸出的數據
print_r($_DSESSION);
echo $discuz_userss;
}
?>

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved