Not Solved Help. Function to do login
#1
Not Solved
Can somebody help me? to do a function to login, I have something similar but it does not work

function login($user,$pass,$remember){
		global $db, $plugins, $mybb;
		require_once "./../inc/functions_user.php";
		require_once "./../inc/datahandlers/login.php";
		$plugins->run_hooks("member_do_login_start");
		// Is a fatal call if user has had too many tries
		verify_post_check($mybb->get_input('my_post_key'));
		$errors = array();
		$logins = login_attempt_check();
		$loginhandler = new LoginDataHandler("get");
		$user = array(
			'username' => $user,
			'password' => $pass,
			'remember' => $remember,
			'imagestring' => ""
		);
		$options = array(
			'fields' => 'loginattempts',
			'username_method' => (int)$mybb->settings['username_method'],
		);

//		$user_loginattempts = get_user_by_username($user['username'], array('fields' => 'loginattempts'));
		$user = get_user_by_username($user['username'], $options);

		$user['loginattempts'] = (int)$user['loginattempts'];
		$loginhandler->set_data($user);
		$validated = $loginhandler->validate_login();	
		if($validated==1){
				$mybb->user = get_user($loginhandler->login_data['uid']);
				my_setcookie("mybbuser", $mybb->user['uid']."_".$mybb->user['loginkey'], null, true);
				$usuario=$mybb->user['username'];
				$logout=md5($mybb->user['loginkey']);
				$loginhandler->complete_login();
				$plugins->run_hooks("member_do_login_end");
				$resultado=1;			
		}else{
				$mybb->input['action'] = "login";
				$mybb->request_method = "get";
				// Is a fatal call if user has had too many tries
				$logins = login_attempt_check($user['uid']);
				$db->update_query("users", array('loginattempts' => 'loginattempts+1'), "uid='".(int)$loginhandler->login_data['uid']."'", 1, true);
				$errors = $loginhandler->get_friendly_errors();
				$user['loginattempts'] = (int)$loginhandler->login_data['loginattempts'];
				$db->update_query("users", array('loginattempts' => 'loginattempts+1'), "username = '".$user['username']."'", 1, true);
				if($user['loginattempts']<5){
						$resultado=0;
				}
				if($user['loginattempts']>5){
					$resultado=2;	
				}
		}
                return $resultado;
}

instead of returning a number is returning html, why?

Sorry I Solved
Reply


Messages In This Thread
Help. Function to do login - by Augustino7 - 2018-07-27, 06:57 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)