The following PHP background login code is free of logon. if the background administrator account is admin and the password is 123456, how can I implement login-free access using the following code, thank you for your PHPcode ;? PhpclassLoginActionextendsBaseAction {// The following PHP background login code is operated by default for login-free
If the background administrator account is admin and the password is 123456, could you tell me how to implement login-free using the following code? thank you!
PHP code
Display (APP_PATH. '/Public/admin/login.html');} // Generate the verification code public function vcode () {import ("ORG. util. image "); Image: buildImageVerify (); // 6, 0, 'PNG ', 'verify'} // logon detection public function check () {if (empty ($ _ POST ['User _ name']) {$ this-> error ('account is required! ');} If (empty ($ _ POST ['User _ pwd']) {$ this-> error ('password required! ');} If (function_exists ('gd _ info') {if (empty ($ _ POST ['verify']) {$ this-> error ('verification code is required! ');} If ($ _ SESSION ['verify']! = Md5 ($ _ POST ['verify ']) {$ this-> error ('verification code error! ') ;}} // Generate the authentication condition $ map = array (); // bind an account to log on to $ map ['admin _ name'] = $ _ POST ['User _ name']; // $ map ["user_status"] = array ('GT ', 0); // status $ rs = D ("Admin. admin "); $ authInfo = $ rs-> where ($ map)-> find (); // use the username, password, and status to authenticate if (false ===$ authInfo) {$ this-> error ('account does not exist or has been disabled! ');} Else {if ($ authInfo ['admin _ pwd']! = Md5 ($ _ POST ['User _ pwd']) {$ this-> error ('incorrect password! ');} // Cache access permission $ _ SESSION [C ('User _ AUTH_KEY')] = $ authInfo ['admin _ id']; $ _ SESSION ['admin _ OK '] = $ authInfo ['admin _ OK']; $ _ SESSION ['admin _ name'] = $ authInfo ['admin _ name']; // $ _ SESSION ['email '] = $ authInfo ['admin _ email']; // $ _ SESSION ['lastlogintime'] = $ authInfo ['admin _ logintime']; // $ _ SESSION ['login _ count'] = $ authInfo ['admin _ count']; // if ($ authInfo ['User _ name'] = 'admin') {// $ _ SESSION ['admin'] = true ;//} // Save the logon information $ ip = get_client_ip (); $ data = array (); $ data ['admin _ id'] = $ authInfo ['admin _ id']; $ data ['admin _ logintime'] = time (); $ data ['admin _ count'] = array ('Exp ', 'admin _ count + 1 '); $ data ['admin _ IP'] = get_client_ip (); $ rs-> save ($ data); redirect ('index. php? S = Admin-index') ;}// the USER logs out of the public function logout () {if (isset ($ _ SESSION [C ('User _ AUTH_KEY ')]) {unset ($ _ SESSION [C ('User _ AUTH_KEY ')]); unset ($ _ SESSION); session_destroy (); $ this-> assign ('jumpurl ', 'index. php? S = Admin-Login '); $ this-> success ('logout successful! ');} Else {$ this-> error (' logged out! ') ;}}?>
------ Solution --------------------
Rewrite the index method
PHP code
public function index(){ if ($_SESSION[C('USER_AUTH_KEY')]){ redirect("index.php?s=Admin-Index"); } //$this->display(APP_PATH.'/Public/admin/login.html'); $_POST['user_name'] = 'admin'; $_POST['user_pwd'] = '123456'; $_POST['verify'] = 1; $_SESSION['verify'] = md5($_POST['verify']); $this->check(); }