<commit_before><?php declare(strict_types=1);

use util\app;
use cnst\assert as cnst_assert;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/deps.php';

Request::setTrustedProxies(
	['172.17.0.0/255'],
    Request::HEADER_X_FORWARDED_ALL
);

$fn_after_locale = function (Request $request, Response $response, app $app){
	$origin = rtrim($app['s3_url'], '/');
	$origin .= ', http://doc.letsa.net';
	$response->headers->set('Access-Control-Allow-Origin', $origin);
};

$fn_before_locale = function (Request $request, app $app){

	setlocale(LC_TIME, 'nl_NL.UTF-8');
	date_default_timezone_set((getenv('TIMEZONE')) ?: 'Europe/Brussels');

	$app['assets']->add([
		'jquery', 'bootstrap', 'fontawesome',
		'footable', 'base.css', 'base.js',
	]);

	$app['assets']->add_print_css(['print.css']);

	error_log('LOGINS: ' . json_encode($app['s_logins']));
};

$fn_before_system = function(Request $request, app $app){

	if ($app['pp_schema'] === '')
	{
		throw new NotFoundHttpException('Systeem ' . $app['pp_system'] . ' niet gevonden.');
	}

	if ($request->query->get('et') !== null)
	{
		$app['email_validate']->validate($request->query->get('et'));
	}

	if ($css = $app['config']->get('css', $app['pp_schema']))
	{
		$app['assets']->add_external_css([$css]);
	}

	$app['log_schema_en'] = true;
};

$fn_before_system_auth = function(Request $request, app $app){

	if (!isset($app['s_logins'][$app['s_schema']]))
	{
		$location = $request->getRequestUri();
		$app['link']->redirect('login', ['system' => $app['pp_system']],
			['location' => $location]);
	}
};

$fn_before_system_guest = function(Request $request, app $app){
	if ($app['pp_guest'])
	{
		if (!$app['intersystem_en'])
		{
			throw new NotFoundHttpException('Guest routes are not enabled in this system.');
		}

		if (!$app['s_system_self'])
		{
			$eland_intersystems = $app['intersystems']->get_eland($app['s_schema']);<commit_msg>log email validation<commit_after><?php declare(strict_types=1);

use util\app;
use cnst\assert as cnst_assert;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/deps.php';

Request::setTrustedProxies(
	['172.17.0.0/255'],
    Request::HEADER_X_FORWARDED_ALL
);

$fn_after_locale = function (Request $request, Response $response, app $app){
	$origin = rtrim($app['s3_url'], '/');
	$origin .= ', http://doc.letsa.net';
	$response->headers->set('Access-Control-Allow-Origin', $origin);
};

$fn_before_locale = function (Request $request, app $app){

	setlocale(LC_TIME, 'nl_NL.UTF-8');
	date_default_timezone_set((getenv('TIMEZONE')) ?: 'Europe/Brussels');

	$app['assets']->add([
		'jquery', 'bootstrap', 'fontawesome',
		'footable', 'base.css', 'base.js',
	]);

	$app['assets']->add_print_css(['print.css']);

	error_log('LOGINS: ' . json_encode($app['s_logins']));
};

$fn_before_system = function(Request $request, app $app){

	if ($app['pp_schema'] === '')
	{
		throw new NotFoundHttpException('Systeem ' . $app['pp_system'] . ' niet gevonden.');
	}

	$app['log_schema_en'] = true;

	if ($request->query->get('et') !== null)
	{
		$app['email_validate']->validate($request->query->get('et'));
	}

	if ($css = $app['config']->get('css', $app['pp_schema']))
	{
		$app['assets']->add_external_css([$css]);
	}
};

$fn_before_system_auth = function(Request $request, app $app){

	if (!isset($app['s_logins'][$app['s_schema']]))
	{
		$location = $request->getRequestUri();
		$app['link']->redirect('login', ['system' => $app['pp_system']],
			['location' => $location]);
	}
};

$fn_before_system_guest = function(Request $request, app $app){
	if ($app['pp_guest'])
	{
		if (!$app['intersystem_en'])
		{
			throw new NotFoundHttpException('Guest routes are not enabled in this system.');
		}

		if (!$app['s_system_self'])
		{
			$eland_intersystems = $app['intersystems']->get_eland($app['s_schema']);
{'fraction_non_alphanumeric': 0.21084477542471491, 'fraction_numerical': 0.00605073306958343, 'mean_word_length': 5.94345718901454, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '2705813', 'n_tokens_mistral': 1611, 'n_tokens_neox': 1548, 'n_words': 241}