<commit_before><?php

session_start();

class auth extends CI_Controller{

	public function __construct(){
		parent::__construct();

		$this->load->model('userdb');

		$this->load->library('session');

		$this->load->helper('url');

	}

	public function index(){

		if(isset($_SESSION['loggedin'])){

			$url = site_url('newpostcont/');

			header("Refresh:0, url='$url'");
		}

		else{

			$this->loginval();

		}
	}

	public function loginval()
	{

		$this->load->helper('form');
		$this->load->library('form_validation');

		$this->form_validation->set_rules('username', 'Username', 'required');
		$this->form_validation->set_rules('password', 'password', '<PASSWORD>');

		if ($this->form_validation->run() === FALSE)
		{
			// echo 'Form not yet validated successfully. Try Again.';

			$this->load->view('authentication/login');

		}
		else
		{

			$data['status'] = 'Not logged in.';

			$res = $this->userdb->checklogin();

			if($res){

				$sessdat = $this->userdb->getdata();

				$this->session->set_userdata($sessdat);

				$_SESSION['loggedin'] = '0';
				$_SESSION['time'] = time();

				// $this->load->view('authentication/viewstat', $data);

				$url = site_url('newpostcont/');

				header("Refresh:0, url='$url'");

			}

			else{

				$this->load->view('authentication/login');

				// $this->loginval();

			}

			// $this->load->view('viewstat', $data);

		}

	}

	public function logout(){

		$this->session->sess_destroy();

		unset($_SESSION['loggedin']);

		$this->loginval();
	}

}

?><commit_msg>Replaced the manual header redirect performed, with the inbuilt function redirect in the URL helper.<commit_after><?php

session_start();

class auth extends CI_Controller{

	public function __construct(){
		parent::__construct();

		$this->load->model('userdb');

		$this->load->library('session');

		$this->load->helper('url');

	}

	public function index(){

		if(isset($_SESSION['loggedin'])){

			redirect('blogcont/', 'refresh');
		}

		else{

			echo "<h3>Access Denied. Try Again.</h3>"

			$this->loginval();

		}
	}

	public function loginval()
	{

		$this->load->helper('form');
		$this->load->library('form_validation');

		$this->form_validation->set_rules('username', 'Username', 'required');
		$this->form_validation->set_rules('password', 'password', '<PASSWORD>');

		if ($this->form_validation->run() === FALSE)
		{
			// echo 'Form not yet validated successfully. Try Again.';

			$this->load->view('authentication/login');

		}
		else
		{

			$data['status'] = 'Not logged in.';

			$res = $this->userdb->checklogin();

			if($res){

				$sessdat = $this->userdb->getdata();

				$this->session->set_userdata($sessdat);

				$_SESSION['loggedin'] = '0';
				$_SESSION['time'] = time();

				// $this->load->view('authentication/viewstat', $data);

				redirect('blogcont/', 'refresh');

			}

			else{

				$this->load->view('authentication/login');

				// $this->loginval();

			}

		}

	}

	public function logout(){

		$this->session->sess_destroy();

		unset($_SESSION['loggedin']);

		redirect('blogcont/', 'refresh');
	}

}

?>
{'fraction_non_alphanumeric': 0.21558441558441557, 'fraction_numerical': 0.001948051948051948, 'mean_word_length': 3.7767441860465114, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 76, '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': '6416102', 'n_tokens_mistral': 1238, 'n_tokens_neox': 1019, 'n_words': 170}