<commit_before><?php

namespace App\Http\Controllers;

use Laravel\Lumen\Routing\Controller as BaseController;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
use Illuminate\Http\Request;
use Elasticsearch\Client as Elasticsearch;

class HomeController extends BaseController
{
	/**
	 * @var ElasticsearchNamespace
	 */
	protected $_elasticSearchClient;

	/**
	 * Initialise our Elasticsearch Client
	 */
	public function __construct() 
	{
		if (!$this->_elasticSearchClient) {
			$this->_elasticSearchClient = new Elasticsearch();
		}
	}

	/**
	 * Render the home view
	 * @return Home view
	 */
    public function index(Request $request) 
    {
    	$results = null;

    	if ($request->isMethod('post') 
    		&& $request->input('search') != ''
    	) {
    		//TODO: Security issue! 
    		//Need to add templating system for escaping
    		//before hitting Elasticsearch.
    		$results = $this->_searchData($request->input('search'));
    	}

	    return view('home.index', array(
	    		'results' 	=> $results,
	    		'search' 	=> $request->input('search')
	    	)
	    );
	}

	/**<commit_msg>Text indentation fix<commit_after><?php

namespace App\Http\Controllers;

use Laravel\Lumen\Routing\Controller as BaseController;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
use Illuminate\Http\Request;
use Elasticsearch\Client as Elasticsearch;

class HomeController extends BaseController
{
	/**
	 * @var ElasticsearchNamespace
	 */
	protected $_elasticSearchClient;

	/**
	 * Initialise our Elasticsearch Client
	 */
	public function __construct() 
	{
		if (!$this->_elasticSearchClient) {
			$this->_elasticSearchClient = new Elasticsearch();
		}
	}

	/**
	 * Render the home view
	 * @return Home view
	 */
    public function index(Request $request) 
    {
    	$results = null;

    	if ($request->isMethod('post') 
    		&& $request->input('search') != ''
    	) {
    		//TODO: Security issue! 
    		//Need to add templating system for escaping
    		//before hitting Elasticsearch.
    		$results = $this->_searchData($request->input('search'));
    	}

	    return view('home.index', array(
	    		'results' 	=> $results,
	    		'search' 	=> $request->input('search')
	    	)
	    );
	}
	
	/**
{'fraction_non_alphanumeric': 0.13250883392226148, 'fraction_numerical': 0.0, 'mean_word_length': 3.1483516483516483, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, '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': '6068861', 'n_tokens_mistral': 735, 'n_tokens_neox': 711, 'n_words': 152}