<commit_before><?php
class User {
	private static $logged_in;
	public static $awaiting_token, $info, $attempts, $timeout;
	
	static function logIn($user=false,$pass=false,$email_authcode=false,$email_authcode_request=false) {
		global $CFG;
		
		$ip = API::getUserIp();
		
		$ch = curl_init($CFG->auth_login_url);
		curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
		curl_setopt($ch,CURLOPT_POSTFIELDS,array('user'=>$user,'pass'=>$<PASSWORD>,'ip'=>$ip,'email_authcode'=>$email_authcode,'email_authcode_request'=>$email_authcode_request));
		curl_setopt($ch,CURLOPT_FRESH_CONNECT,TRUE);
		
		$result1 = curl_exec($ch);
		$result = json_decode($result1,true);
		curl_close($ch);
		
		if (!empty($result['attempts']))
			self::$attempts = $result['attempts'];
		
		if (!empty($result['timeout']))
			self::$timeout = $result['timeout'];
		
		if (empty($result) || !empty($result['error'])) {
			return false;
		}
		elseif (!empty($result['message'])) {
			$_SESSION['session_id'] = $result['session_id'];
			$_SESSION['session_key'] = $result['session_key'];
			$_SESSION['nonce'] = $result['nonce'];
			return $result;
		}
	}
	
	static function verifyLogin($query) {
		global $CFG;
		
		if (isset($query['User']['verifyLogin']['results'][0]))
			$result = $query['User']['verifyLogin']['results'][0];

		if (!empty($result['attempts']))
			self::$attempts = $result['attempts'];
		
		if (empty($_SESSION['session_id']))
			return false;

		if (!empty($result['error']) || !empty($query['error']) || !isset($result)) {
			$session_id = session_id();
			if (!empty($session_id)) {
				session_destroy();
				$_SESSION = array();
			}
			return false;
		}
		
		if (!empty($result['message']) && $result['message'] == 'awaiting-token') {
			self::$awaiting_token = true;
			return true;
		}<commit_msg>Login attempts was not available in session.<commit_after><?php
class User {
	private static $logged_in;
	public static $awaiting_token, $info, $attempts, $timeout;
	
	static function logIn($user=false,$pass=false,$email_authcode=false,$email_authcode_request=false) {
		global $CFG;
		
		$ip = API::getUserIp();
		
		$ch = curl_init($CFG->auth_login_url);
		curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
		curl_setopt($ch,CURLOPT_POSTFIELDS,array('user'=>$user,'pass'=>$<PASSWORD>,'ip'=>$ip,'email_authcode'=>$email_authcode,'email_authcode_request'=>$email_authcode_request));
		curl_setopt($ch,CURLOPT_FRESH_CONNECT,TRUE);
		
		$result1 = curl_exec($ch);
		$result = json_decode($result1,true);
		curl_close($ch);
		
		if (!empty($result['attempts'])) {
			self::$attempts = $result['attempts'];
			$_SESSION['attempts'] = $result['attempts'];
		}
		
		if (!empty($result['timeout'])) {
			self::$timeout = $result['timeout'];
			$_SESSION['attempts'] = $result['timeout'];
		}
		
		if (empty($result) || !empty($result['error'])) {
			return false;
		}
		elseif (!empty($result['message'])) {
			$_SESSION['session_id'] = $result['session_id'];
			$_SESSION['session_key'] = $result['session_key'];
			$_SESSION['nonce'] = $result['nonce'];
			unset($_SESSION['attempts']);
			unset($_SESSION['timeout']);
			return $result;
		}
	}
	
	static function verifyLogin($query) {
		global $CFG;
		
		if (isset($query['User']['verifyLogin']['results'][0]))
			$result = $query['User']['verifyLogin']['results'][0];

		if (!empty($result['attempts']) && (empty($_SESSION['attempts']) || $result['attempts'] > $_SESSION['attempts']))
			self::$attempts = $result['attempts'];
		else if (!empty($_SESSION['attempts']))
			self::$attempts = $_SESSION['attempts'];
		
		if (empty($_SESSION['session_id']))
			return false;

		if (!empty($result['error']) || !empty($query['error']) || !isset($result)) {
			$session_id = session_id();
			if (!empty($session_id)) {
				session_destroy();
				$_SESSION = array();
			}
			return false;
		}
		
		if (!empty($result['message']) && $result['message'] == 'awaiting-token') {
			self::$awaiting_token = true;
			return true;
		}
{'fraction_non_alphanumeric': 0.21309403437815977, 'fraction_numerical': 0.0020222446916076846, 'mean_word_length': 5.810671256454389, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5356475', 'n_tokens_mistral': 1532, 'n_tokens_neox': 1322, 'n_words': 200}