php - Active and deactive user working indatabase how to incoperate in script -
active , deactivate working in database ie becoming 0 , 1 in column status. unable change ls or config file after login should check in database table user column status whether 0 or 1 , if 1 (user active) should go home page otherwise should go error page (user not activated). how create public function this, , needed modifications in config file
part of ls file control functions
public function init() { if(in_array(self::curpage(), $this->config['pages']['everyone'])){ /** * no redirects page can accessed * whether he/she logged in or not */ }else if($this->loggedin === true && in_array(self::curpage(), $this->config['pages']['no_login'])){ self::redirect($this->config['pages']['home_page']); }else if($this->loggedin === false && array_search(self::curpage(), $this->config['pages']['no_login']) === false){ self::redirect($this->config['pages']['login_page']); } $this->initcalled = true; } /** * username/password wrong
*/ return false; }else if(is_array($login) && $login['status'] == "blocked"){ return false; } else if(is_array($login) && $login['stat'] == "deactive"){ if($this->initcalled){ self::redirect($this->config['pages']['deactive_page']); } return $login; } else{ /** * user id \fr\ls::login() */ $uid = $login; /** config file
require __dir__ . "/src/ls.php"; $config = array( "basic" => array( "company" => "********.in", "email" => "**********@gmail.com" ), "db" => array( "host" => "**********.com", "port" => 3306, "username" => "*********", "password" => "***********", "name" => "********", "table" => "users" ), "features" => array( "auto_init" => true, "two_step_login" => true ), /** * these localhost paths, change yours */ "pages" => array( "no_login" => array( "/user/", "/user/reset.php", "/user/registercomember.php" ), "everyone" => array( "/user/status.php", "/tips/all.php" ), "login_page" => "/user/login.php", "home_page" => "/tips/secure.php", ), "two_step_login" => array( "instruction" => "a token sent e-mail address. please see mail in inbox , paste token found in textbox below :", "send_callback" => function(&$ls, $userid, $token){ $email = $ls->getuser("email", $userid); $ls->sendmail($email, "verify yourself", "someone tried login account. if you, use following token complete logging in : <blockquote>". $token ."</blockquote>if not you, ignore email , please consider change account's password."); } ) ); $ls = new \fr\ls($config);
Comments
Post a Comment