<commit_before><?php

class Controller {

	protected $token = '<KEY>';
	protected $request;
	protected $auth = array('/question/add', '/deal/add', '/badge/add', '/user/login');

	function __construct() {

		if(!empty($_SESSION['alert'])){
			unset($_SESSION['alert']);
		}

		if(!empty($this->uses)){
			foreach($this->uses as $use){
				$this->loadModel($use);
			}
		}

		// $this->request = $this->get_header();
		$this->request = $_SERVER;

		if(!isset($this->request['HTTP_AUTH_TOKEN']) ||
			$this->request['HTTP_AUTH_TOKEN'] != $this->token){

			$url = $this->request['REQUEST_URI'];

			if(!in_array($url, $this->auth)){
				// $this->send_message(array(
				// 	'code' => '401',
				// 	'name' => 'authentification fail',
				// 	'message' => 'wrong token'));
				// die();
			}else{
				if(!$this->sessionCheck('user') && $url != '/user/login'){
					$_SESSION['redirect']['from'] = $url;
					$this->redirect('/user/login');
				}
			}


		}
	}

	public function init($f3, $params = null){
		if(!empty($params['ok'])){
			$this->loadModel('Model');
			//$this->Model->generate_categories();
			// $this->Model->generate_questions();
			$this->Model->generate_responses();
		}
	}

	/**
	*	Rediriger vers une page
	**/
	public function redirect($url){
		header('Location:' . $url);
	}

	/**
	*	Retourne le tableau contenant les Headers de la requete
	*	@return Request Header
	**/
	protected function get_header(){
		if (!function_exists('apache_request_headers')) {
			function apache_request_headers() {
				foreach($_SERVER as $key=>$value) {
					if (substr($key,0,5)=="HTTP_") {<commit_msg>commit and sync<commit_after><?php

class Controller {

	protected $token = '<KEY>';
	protected $request;
	protected $auth = array('/question/add', '/deal/add', '/badge/add', '/user/login');

	function __construct() {

		if(!empty($_SESSION['alert'])){
			unset($_SESSION['alert']);
		}

		// automatic load model
		if(!empty($this->uses)){
			foreach($this->uses as $use){
				$this->loadModel($use);
			}
		}

		// $this->request = $this->get_header();
		$this->request = $_SERVER;

		if(!isset($this->request['HTTP_AUTH_TOKEN']) ||
			$this->request['HTTP_AUTH_TOKEN'] != $this->token){

			$url = $this->request['REQUEST_URI'];

			if(!in_array($url, $this->auth)){
				// $this->send_message(array(
				// 	'code' => '401',
				// 	'name' => 'authentification fail',
				// 	'message' => 'wrong token'));
				// die();
			}else{
				if(!$this->sessionCheck('user') && $url != '/user/login'){
					$_SESSION['redirect']['from'] = $url;
					$this->redirect('/user/login');
				}
			}


		}
	}

	private function init($f3, $params = null){
		if(!empty($params['ok'])){
			$this->loadModel('Model');
			//$this->Model->generate_categories();
			// $this->Model->generate_questions();
			$this->Model->generate_responses();
		}
	}

	/**
	*	Redirect to page
	*	(but useless with framework features)
	*	@param string url
	**/
	public function redirect($url){
		header('Location:' . $url);
	}

	/**
	*	Retourne le tableau contenant les Headers de la requete
	*	@return Request Header
	**/
	protected function get_header(){
		if (!function_exists('apache_request_headers')) {
			function apache_request_headers() {
				foreach($_SERVER as $key=>$value) {
					if (substr($key,0,5)=="HTTP_") {
{'fraction_non_alphanumeric': 0.22131147540983606, 'fraction_numerical': 0.0036429872495446266, 'mean_word_length': 3.6937321937321936, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 55, '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': '3356130', 'n_tokens_mistral': 1308, 'n_tokens_neox': 1128, 'n_words': 200}