<? PHP
// Define the operation page
Define ('curscr should pt', 'logging ');
// Contains public files
Require_once './include/common. Inc. php ';
// Contains the MISC function File
Require_once discuz_root. './include/Misc. func. php ';
// Judge the action
// Cancel
If ($ action = 'logout '&&! Empty ($ formhash) & $ formhash = formhash ){
// Clear cookies
Clearcookies ();
// Reset the user status to "visitor"
$ Groupid = 7;
$ Discuz_uid = 0;
// Clear the user name and password
$ Discuz_user = $ discuz_pw = '';
// Reset the Page Style
$ Styleid = $ _ dcache ['settings'] ['styleid'];
// The logout success page is displayed.
Showmessage ('logout _ succeed', dreferer ());
}
// Login
Elseif ($ action = 'login '){
// Determine whether the user is a tourist
If ($ discuz_uid ){
// The logon success page is displayed.
Showmessage ('login _ succeed', $ indexname );
}
// Field name of the Login User Name
$ Field = isset ($ loginfield) & $ loginfield = 'uid '? 'Uid': 'username ';
// Check the verification code
// Get secure code checking status (Pos.-2)
$ Seccodecheck = substr (sprintf ('% 05b', $ seccodestatus),-2, 1 );
// Determine whether to submit for login
If (! Submitcheck ('loginsubmit ', 1, $ seccodecheck )){
// Display the login page
$ Discuz_action = 6;
$ Referer = dreferer ();
$ Thetimenow = '(gmt'. ($ timeoffset> 0? '+': ''). $ Timeoffset .')'.
Gmdate ("$ dateformat $ timeformat", $ timestamp ++ $ timeoffset * 3600 ).
$ Styleselect = '';
$ Query = $ db-> query ("select styleid, name from {$ tablepre} styles where available = '1 '");
While ($ styleinfo = $ db-> fetch_array ($ query )){
$ Styleselect. = "<option value = \" $ styleinfo [styleid] \ "> $ styleinfo [name] </option> \ n ";
}
$ _ Dcookie ['cookietime'] = isset ($ _ dcookie ['cookietime'])? $ _ Dcookie ['cookietime']: 2592000;
$ Cookietimecheck = array (isset ($ _ dcookie ['cookietime'])? Intval ($ _ dcookie ['cookietime']): 2592000) => 'checked ');
If ($ seccodecheck ){
$ Seccode = random (4, 1 );
}
Include template ('login ');
} Else {
// Process Login
// Leave user information empty
$ Discuz_uid = 0;
$ Discuz_user = $ discuz_pw = $ discuz_secques = $ md5_password = '';
$ Member = array ();
// Determine if the logon is restricted. 0, 1, 2, and 3 are returned. Statement in Misc. func. php
$ Loginperm = logincheck ();
If (! $ Loginperm ){
// Display restricted Login
Showmessage ('login _ strike ');
}
// Security question handling. A string of characters or null is returned. Statement in global. func. php
$ Secques = quescrypt ($ questionid, $ answer );
// Determine whether to log on to the security question page
If (isset ($ loginauth )){
$ Field = 'username ';
$ Password = 'verified ';
List ($ username, $ md5_password) = explode ("\ t", authcode ($ loginauth, 'decode '));
} Else {
$ Md5_password = MD5 ($ password );
$ Password = preg_replace ("/^ (. {". Round (strlen ($ password)/4). "}) (. + ?) (. {". Round (strlen ($ password)/6)."}) $/s "," http://www.cnblogs.com/kuyuecs/admin/file://1##/3 ", $ password );
}
// Query the data tables members and usergroups.
$ 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 '");
// Retrieve user authentication information including uid, user name, password, security question, management permission, user group ID, page style, last access, last post, and whether stealth is allowed
$ Member = $ db-> fetch_array ($ query );
// Verify Login
If ($ member ['discuz _ uid'] & $ member ['discuz _ PW '] = $ md5_password ){
// Verify security questions
If ($ member ['discuz _ secques'] = $ secques ){
// Security question matching
// Import the variable from the array to the current symbol table
Extract ($ member );
// Process User Name
$ Discuz_userss = $ discuz_user;
$ Discuz_user = addslashes ($ discuz_user );
// Determine the stealth mode
If ($ allowinvisible & $ loginmode = 'invisable') | $ loginmode = 'normal '){
// Update the current mode of the members table User: stealth or 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 ));
// Write cookie
Dsetcookie ('cookietime', $ cookietime, 31536000 );
Dsetcookie ('auth', authcode ("$ discuz_pw \ t $ discuz_secques \ t $ discuz_uid", 'encoding'), $ cookietime );
$ Sessionexists = 0;
// Determine whether the Member is waiting for verification
If ($ groupid = 8 ){
Showmessage ('login _ succeed_inactive_member ', 'memcp. php ');
} Else {
Showmessage ('login _ succeed', dreferer ());
}
} Elseif (empty ($ secques )){
// The security question does not match and the security question is not blank
$ Username = dhtmlspecialchars ($ member ['discuz _ user']);
$ Loginmode = dhtmlspecialchars ($ loginmode );
$ Styleid = intval ($ styleid );
$ Cookietime = intval ($ cookietime );
// Encrypt the accepted user name and password
$ Loginauth = authcode (addslashes ($ member ['discuz _ user']). "\ t ". addslashes ($ member ['discuz _ PW ']), 'encode ');
// Display and answer security questions
Include template ('login _ secques ');
Dexit ();
}
}
// Generate a Password error log
$ Errorlog = "<? PHP exit ('Access denied ');?> \ T ". $ timestamp." \ t ".
Dhtmlspecialchars ($ member ['discuz _ user']? $ Member ['discuz _ user']: stripslashes ($ username). "\ t ".
$ Password. "\ t ".
($ Secques? "Ques #". dhtmlspecialchars ($ questionid): '')." \ t ".
$ Onlineip. "\ n ";
Loginfailed ($ loginperm );
// Add log records to log files
@ $ Fp = fopen (discuz_root. './forumdata/illegallog. php', 'A ');
@ Flock ($ FP, 2 );
@ Fwrite ($ FP, $ errorlog );
@ Fclose ($ FP );
// Display the logon error page
Showmessage ('login _ invalid', null, 'halted ');
}
}
Else {
Showmessage ('undefined _ Action ');
}
?>