<commit_before><?php
/**
 * Asynctive Web User Settings Controller
 * @author <NAME>
 */
class Settings extends Site_Controller
{
	public function __construct()
	{
		parent::__construct('user_settings');		
	}
	
	public function index()
	{
		$this->load->library('form_validation');
		if (!empty($_POST))
		{
			unset($_SESSION['verification_sent']);
			$email = $this->input->post('update_email');
			$new_password = $this->input->post('update_password');
			
			if ($new_password != '')
				$this->form_validation->set_rules('update_password', '<PASSWORD>', 'min_length[6]|max_length[72]');
						
			$this->form_validation->set_rules($this->USER_UPDATE_RULES);
			if ($this->form_validation->run())
			{
				$data = array();
				$user = $this->user_model->getUserById($_SESSION['user_id']);
				
				$this->db->trans_start();
				// They aren't verified anymore
				if ($email != $user->email)
				{
					$data['email_verified'] = FALSE;
					$_SESSION['email_verified'] = FALSE;
					$this->resend_verification(FALSE);
				}
				
				$data['email'] = $email;
				if ($new_password != '')
					$data['password'] = password_hash($new_password, PASSWORD_DEFAULT);
				
				$this->user_model->updateUserById($data, $_SESSION['user_id']);
				
				$this->db->trans_complete();				
				if ($this->db->trans_status() !== FALSE)
				{
					$this->data['updated'] = TRUE;
				}
			}
			
			$this->data['user_email'] = $email;
		}
		
		else
		{
			$user = $this->user_model->getUserById($_SESSION['user_id']);
			$this->data['user_email'] = $user->email;
		}
		
		$this->_render('pages/user_settings.php');
	}
	
	public function resend_verification($redirect = TRUE)
	{
		$this->load->helper(array('uuid', 'random'));
		$this->load->model('pending_email_model');
		
		// Don't send one if already verified
		$user = $this->user_model->getUserById($_SESSION['user_id']);
		if (!$user->email_verified)
		{
			$this->pending_email_model->deleteVerificationByUserId($_SESSION['user_id']);<commit_msg>More bug fixing<commit_after><?php
/**
 * Asynctive Web User Settings Controller
 * @author <NAME>
 */
class Settings extends Site_Controller
{
	public function __construct()
	{
		parent::__construct('user_settings');		
	}
	
	public function index()
	{
		$this->load->library('form_validation');
		if (!empty($_POST))
		{
			unset($_SESSION['verification_sent']);
			$email = $this->input->post('update_email');
			$new_password = $this->input->post('update_password');
			
			if ($new_password != '')
				$this->form_validation->set_rules('update_password', '<PASSWORD>', 'min_length[6]|max_length[72]');
						
			$this->form_validation->set_rules($this->USER_UPDATE_RULES);
			if ($this->form_validation->run())
			{
				$data = array();
				$data['email'] = $email;
								
				$this->db->trans_start();
				
				if ($new_password != '')
					$data['password'] = password_hash($new_password, PASSWORD_DEFAULT);
				
				// They aren't verified anymore
				$old_user = $this->user_model->getUserById($_SESSION['user_id']);
				if ($email != $old_user->email)
				{
					$data['email_verified'] = FALSE;
					$_SESSION['email_verified'] = FALSE;
					$this->resend_verification(FALSE);
				}
				
				$this->user_model->updateUserById($data, $_SESSION['user_id']);
				
				$this->db->trans_complete();				
				if ($this->db->trans_status() !== FALSE)
				{
					$this->data['updated'] = TRUE;
				}
			}
			
			$this->data['user_email'] = $email;
		}
		
		else
		{
			$user = $this->user_model->getUserById($_SESSION['user_id']);
			$this->data['user_email'] = $user->email;
		}
		
		$this->_render('pages/user_settings.php');
	}
	
	public function resend_verification($redirect = TRUE)
	{
		$this->load->helper(array('uuid', 'random'));
		$this->load->model('pending_email_model');
		
		// Don't send one if already verified
		$user = $this->user_model->getUserById($_SESSION['user_id']);
		if (!$_SESSION['email_verified'])
		{
			$this->pending_email_model->deleteVerificationByUserId($_SESSION['user_id']);
{'fraction_non_alphanumeric': 0.19185610791906071, 'fraction_numerical': 0.0014988758431176618, 'mean_word_length': 3.93711467324291, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 88, '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': '2253722', 'n_tokens_mistral': 1621, 'n_tokens_neox': 1313, 'n_words': 187}